Пример #1
0
 private void OnAllSelected()
 {
     if (SubGroupSelector == null)
     {
         if (Selection.SelectedItems.Count() != this.ItemsSource.Count())
         {
             selectionZone.AddItems(ItemsSource);
         }
         else
         {
             selectionZone.ClearSelection();
         }
     }
     else
     {
         //source is grouped... need to recursively select them all.
         var flattenedItems = this.ItemsSource?.SelectManyRecursive(x => SubGroupSelector(x));
         if (flattenedItems.Count() != Selection.SelectedItems.Count())
         {
             selectionZone.AddItems(flattenedItems);
         }
         else
         {
             selectionZone.ClearSelection();
         }
     }
 }
Пример #2
0
 private void OnHeaderToggled(HeaderItem <TItem> headerItem)
 {
     // Doesn't seem to be any difference in the behavior for clicking the Header vs the checkmark in the header.
     //does selection contain this item already?
     if (Selection.SelectedItems.Contains(headerItem.Item))
     {
         //deselect it and all children
         var items = SubGroupSelector(headerItem.Item)?.RecursiveSelect <TItem, TItem>(r => SubGroupSelector(r), i => i).Append(headerItem.Item);
         SelectionZone.RemoveItems(items);
     }
     else
     {
         //select it and all children
         var items = SubGroupSelector(headerItem.Item)?.RecursiveSelect <TItem, TItem>(r => SubGroupSelector(r), i => i).Append(headerItem.Item);
         SelectionZone.AddItems(items);
     }
 }