0

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?

Vijay
  • 663
  • 4
  • 15
Audo Anzon
  • 103
  • 1
  • 9
  • Lets suppose you have a header, where your desired result is displayed for a non-changing collection with non-changing item properties (I can probably provide you with this). You are asking for trouble once any changes are involved. (1) [observing the group items collection](http://stackoverflow.com/questions/1675429/how-do-i-update-an-ivalueconverter-on-collectionchanged) (2) observing the group item property changes. – grek40 Jan 31 '17 at 08:15
  • So if your problem is related to dynamic changes, please show that you already have a static solution. Otherwise your question might be to broad since it is touching many different issues. – grek40 Jan 31 '17 at 08:16

0 Answers0