static void EnableMultiSelectChanged(DependencyObject s, DependencyPropertyChangedEventArgs args) { TreeListView tree = (TreeListView)s; var wasEnable = (bool)args.OldValue; var isEnabled = (bool)args.NewValue; if (wasEnable) { tree.RemoveHandler(TreeViewItem.MouseDownEvent, new MouseButtonEventHandler(ItemClicked)); tree.RemoveHandler(TreeViewItem.MouseDoubleClickEvent, new MouseButtonEventHandler(MouseDoubleClick)); tree.RemoveHandler(TreeView.KeyDownEvent, new KeyEventHandler(KeyDown)); tree.RemoveHandler(TreeView.KeyUpEvent, new KeyEventHandler(KeyUp)); } if (isEnabled) { SelectedTreeItems = new List <object>(); tree.AddHandler(TreeViewItem.MouseDownEvent, new MouseButtonEventHandler(ItemClicked), true); tree.AddHandler(TreeViewItem.MouseDoubleClickEvent, new MouseButtonEventHandler(MouseDoubleClick), true); tree.AddHandler(TreeView.KeyDownEvent, new KeyEventHandler(KeyDown)); tree.AddHandler(TreeView.KeyUpEvent, new KeyEventHandler(KeyUp)); } }
private static void UpdateAnchorAndActionItem(TreeListView tree, TreeListViewItem item) { SetAnchorItem(tree, item); }
private static void MakeToggleSelection(TreeListView tree, TreeListViewItem item) { SetIsSelected(item, !GetIsSelected(item)); UpdateAnchorAndActionItem(tree, item); }
public static List <TreeListViewItem> GetSelectedTreeViewItems(TreeListView tree) { return(GetExpandedTreeViewItems(tree).Where(i => GetIsSelected(i)).ToList()); }