private void HandleSingleSelection(TreeViewItem newSelectedItem) { ClearAllSelections(); newSelectedItem.IsSelected = true; SelectedTreeViewItems.Add(newSelectedItem); _lastSelectedItem = newSelectedItem; }
private void Select(TreeViewItem element) { if (element.IsSelected) { return; } element.IsSelected = true; _lastSelectedItem = element; SelectedTreeViewItems.Add(element); element.BringIntoView(); if (AutoExpandSelected) { TryExpandTree(element); } }
private void HandleShiftKeySelection(TreeViewItem newSelectedItemContainer) { if (_lastSelectedItem != null) { ClearAllSelections(); var items = GetFlatTreeViewItems(this); var firstItemPos = items.IndexOf(_lastSelectedItem); var lastItemPos = items.IndexOf(newSelectedItemContainer); Sort(ref firstItemPos, ref lastItemPos); for (int i = firstItemPos; i <= lastItemPos; ++i) { items[i].IsSelected = true; SelectedTreeViewItems.Add(items[i]); } } }
private void HandleControlKeySelection(TreeViewItem newSelected) { if (SelectedTreeViewItems.Contains(newSelected)) { newSelected.IsSelected = false; SelectedTreeViewItems.Remove(newSelected); if (_lastSelectedItem != null) { _lastSelectedItem.IsSelected = true; } _lastSelectedItem = null; } else { if (_lastSelectedItem != null) { _lastSelectedItem.IsSelected = true; } SelectedTreeViewItems.Add(newSelected); _lastSelectedItem = newSelected; } }