WPF - Group Styles: Can we only bind to the "Name" property?
.net, .net-4.0, c#, wpf
Solution
By default `DataContext` in `GroupStyle` you can bind to this CollectionViewGroup Properties. But of course you can set any other `BindingSource` if you need.
If you want the first object in your group use:
<TextBlock Text="{Binding Path=Items[0].YourStringProperty}" />
Problem
I am trying to create an ItemsControl which is charged with displaying various items sorted by metadata. Each item can have multiple metadata. For example, an item of type "Conversation" could have a "Chapter", "Act" and "Volume" metadata. Upon searching how grouping worked in WPF, I found out about GroupStyles and the PropertyGroupDescription class. I created my own class which inherits from PropertyGroupDescription and which returns an object of type "Metadata". Is there anyway that in my ItemsControl's GroupStyle DataTemplate I can bind to the object returned (i.e.: the "Metadata" object) and then display its properties as I wish ? Or am I forced to bind to "Name" ? In other words: ``` <ItemsControl.GroupStyle> <GroupStyle> <GroupStyle.HeaderTemplate> <DataTemplate> Am I forced to bind to "Name" here ? </DataTemplate> </GroupStyle.HeaderTemplate> </GroupStyle> </ItemsControl.GroupStyle> ```