Beispiel #1
0
        /// <summary>
        /// Collapses siblings of <param name="Item"/>.
        /// </summary>
        public static void CollapseSiblings(this TreeViewItem Item)
        {
            var Parent = Item.GetParent().As <FrameworkElement>();

            while (!Parent.Is <TreeViewItem>())
            {
                if (Parent == null || Parent.Is <TreeView>())
                {
                    break;
                }
                Parent = Parent.GetParent().As <FrameworkElement>();
            }
            ItemsControlExtensions.CollapseSiblings(Parent as ItemsControl, Item);
        }
Beispiel #2
0
        static void RegisterSelectNoneOnEmptySpaceClick(object sender, MouseButtonEventArgs e)
        {
            var ItemsControl = sender as ItemsControl;

            if (ItemsControlExtensions.GetSelectNoneOnEmptySpaceClick(ItemsControl) && e.LeftButton == MouseButtonState.Pressed)
            {
                if ((ItemsControl is TreeView && !e.OriginalSource.Is <TreeViewItem>()) ||
                    (ItemsControl is DataGrid && !e.OriginalSource.Is <DataGridRow>()) ||
                    (ItemsControl is ListBox && !e.OriginalSource.Is <ListBoxItem>()))
                {
                    ItemsControl.TryClearSelection();
                }
            }
        }