If I have a HyperlinkColumn that uses the ContentBinding to change the display text of the URL, and then group by that column, the Url (Key) is shown, not the ContentBinding.
For example:
<
igDataGrid:HyperlinkColumn Key="Url" ContentBinding="{Binding Name}" TargetName="_blank" />
If I use this, in the grid, ungrouped, I see the product Name field with the link going to the Url field, which is great. But when I group by this column, the group header shows the Url.
Is there any way to change this behavior? I tried with a ValueConverter, but the "value" being passed is already the Url, so I can't do anything about it at that point.
Thanks,Keith
Thanks Stephen, that's how I was trying to use the ValueConverter - within the GroupByItemTemplate. I should've been more specific. I figured it out, so you can stop reading.... But here's the details in case anyone else is tyring the same thing.
I had these resources:
<local:LinkConverter x:Key="LinkConverter1" /><local:LinkComparer x:Key="LinkComparer1" /><DataTemplate x:Key="DataTemplateProductGroup" > <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Value, Converter={StaticResource LinkConverter1}}" /> </StackPanel></DataTemplate>
And this column:
<igDataGrid:HyperlinkColumn Key="Url" ContentBinding="{Binding Name}" TargetName="_blank" GroupByItemTemplate="{StaticResource DataTemplateProductGroup}" GroupByComparer="{StaticResource LinkComparer1}"/>
The ItemSource for the grid is a list of Product objects (which have Url and Name properties).
The problem was that both the LinkConverter and LinkComparer get passed the string value of the Url property, not the Product object, so I had no access to the Name.
With the LinkComparer it really didn't matter, since if the Name was different the Url was too, so grouping on Url was fine. So, I got rid of the custom Comparer. With the LinkConverter I could pass the Records (instead of Value) and use the first one (since if they're grouped together they should all be the same).
With the LinkConverter, I still need the Name for the display. So, instead of Value, I changed to pass the Records. Then I use the first one (since if they're grouped together they should all be the same) and use it's Name for the display.
So, now I have:
<local:LinkConverter x:Key="LinkConverter1" /><DataTemplate x:Key="DataTemplateProductGroup" > <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Records, Converter={StaticResource LinkConverter1}}" /> </StackPanel></DataTemplate>
<igDataGrid:HyperlinkColumn Key="Url" ContentBinding="{Binding Name}" TargetName="_blank" GroupByItemTemplate="{StaticResource DataTemplateProductGroup}" >
Thanks, Keith
Hi Keith,
Every Column object in the XamWebGrid has a property called GroupByItemTemplate. Which can be used to customize the content displayed in a GroupByRow.
The DataContext of this DataTemplate is of type GroupByDataContext which has the following properties:
Value, Records, and Count.
The following help article goes into more detail on how to use the GroupByItemTemplate and even contains some sample code.
Custom GroupByRow Display
Hope this helps.
-SteveZ