I create a collectionviewsource that binds to my collection (to group the items)
<CollectionViewSource x:Key="ColViewSource" Source="{Binding Collection}">
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="Cat"/>
</CollectionViewSource.GroupDescriptions>
</CollectionViewSource>
and I want to edit the group header based on a value from property in a collectionitem. My Groupheader looks like this:
<StackPanel Orientation="Horizontal" Height="50">
<CheckBox Style="{StaticResource GroupCheckBox}" Margin="2,0,0,0" x:Name="chone" IsChecked="{Binding ischone}" VerticalAlignment="Center" IsHitTestVisible="False"/>
<TextBlock Text="{Binding Name}" FontSize="25" VerticalAlignment="Center" Foreground="White" />
<TextBlock Text="{Binding ItemCount}" FontSize="25" FontWeight="Bold" VerticalAlignment="Center" Foreground="White" />
</StackPanel>
Lets say the first group contains 1 item/row. This item has a textbox. What I want to do is Set the checkbox for this groupheader to True when the textbox has any text. (if txtbox.text != " ") meaning that all items in this group have been filled in.
Next group has 2 items, both of them have one checkbox each. Now i want to set this groupheaders checkbox to True when the checkboxes in the items are both true.
etc
I found this link: https://social.msdn.microsoft.com/Forums/vstudio/en-US/758fceb5-90a6-4e66-b648-03b07dc8a139/iterate-over-collectionviewgroups-collection?forum=wpf
with the answer :
foreach (CollectionViewGroup group in this.view.Groups){MessageBox.Show(group.Name.ToString()); }
..but i cant get that code to work My problem seems to be getting each group / groupheader / values from somewhere (Collectionviewsource?) as CollectionViewGroup object?. If I could do that I could check if the groups Name equals a certain value and perform my checks for item property values from there and set the groups checkbox as well I guess. Any suggestions?