Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Sadly its not as straightforward as it needs to be,</p> <p>Remember that a group's header <code>CheckBox</code> has a <code>DataContext</code> which is a special kind of object called <code>GroupItem</code>. In this <code>GroupItem</code> there is <code>Name</code> property which is the value that the group represents i.e. the common value on the basis of which grouping has occurred.</p> <p>Many people confuse this with the group description property e.g. assuming you have added a <code>GroupDescription</code> with property <code>EmployeeStatus</code> in your <code>CollectionView</code> of employees, then <code>GroupItem.Name</code> is NOT <code>EmployeeStatus</code> but it is in fact the value on which group was created such as <code>Present</code>, <code>Absent</code>, <code>OnLeave</code> etc.</p> <p>Having this knowledge, lets try to achieve what you seek ... </p> <ol> <li><p>We name the header checkbox, say "HeaderCheckBox"</p> <pre><code>&lt;CheckBox x:Name="HeaderCheckBox" ...&gt; </code></pre></li> <li><p>We handle <code>Button.Click</code> (a bubbling attached event) at the ListView level.</p> <pre><code>&lt;ListView Button.Click="HandleCheckBoxClick" ...&gt; </code></pre></li> <li><p>In the handler <code>HandleButtonClick</code> we do the following code....</p> <pre><code>private void HandleCheckBoxClick(object sender, RoutedEventArgs e) { var checkBox = e.OriginalSource as CheckBox; if (checkBox != null &amp;&amp; checkBox.Name == "HeaderCheckBox") { var groupItem = checkBox.DataContext as GroupItem; //// Assuming MyItem is the item level class and MyGroupedProperty //// is the grouped property that you have added to the grouped //// description in your CollectionView. foreach (MyItem item in groupItem.Items) { //// Place your code for the items under that particular group. } } } </code></pre></li> </ol> <p>Sadly this is the only way to achieve what you seek. If you are using MVVM, then the entire code will have to be done through an attached behavior.</p> <p>Let me know if this helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload