I am using a datagrid with a combox that should change the grouping field. I am using the following xaml to define the general grouping template :
<DataGrid.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander>
<Expander.Header>
<StackPanel Orientation="Horizontal">
<TextBlock Text="NEEDS TO BE BINDED..."/>
</StackPanel>
</Expander.Header>
<ItemsPresenter />
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</DataGrid.GroupStyle>
I only need to be able to 'reach' that TextBlock within the expander to be able to output the selected grouping applied.
Please help....
If you want to display the common value of the property being grouped by, that will be available as CollectionViewGroup.Name, so you can just do:
I have solved my issue by adding a nested class that contains the currently selected grouping (which i manually set ofcourse) + more details i need. Then binding to the class property by using :
<TextBlock Text="{Binding Source={StaticResource GroupingSubject},Path=Name}"/>
Ofcourse that i had to declare the class within the xaml resources as follows :
<local:GroupingName x:Key="GroupingName"/>
My nested class looks as follows :
Now all is well...