Ejemplo n.º 1
0
        void ComboBox_GotFocus(object sender, RoutedEventArgs e)
        {
            var item = WpfTreeNavigation.TryFindParent <ListBoxItem>((ComboBox)sender);

            if (item != null)
            {
                item.IsSelected = true;
            }
        }
        public new void Focus()
        {
            var firstButton = WpfTreeNavigation.TryFindChild <Button>(this);

            if (firstButton == null)
            {
                return;
            }
            firstButton.Focus();
        }
        public new void Focus()
        {
            var firstButton = WpfTreeNavigation.TryFindChild <Button>(this);

            if (firstButton != null)
            {
                firstButton.Focus();
            }
            else
            {
                TreeView.Focus();
            }
        }
Ejemplo n.º 4
0
        void WatchListAutoCompleteCell_CommandEntered(object sender, EventArgs e)
        {
            if (SelectedNode == null)
            {
                return;
            }
            if (WatchType != WatchListType.Watch)
            {
                return;
            }

            var cell = ((WatchListAutoCompleteCell)sender);

            SelectedNode.Name = cell.CommandText;
            if (WatchType == WatchListType.Watch)
            {
                ParentPad.RefreshPad();
            }

            for (int i = 0; i < MyList.Items.Count; i++)
            {
                TreeViewItem child = (TreeViewItem)MyList.ItemContainerGenerator.ContainerFromIndex(i);
                child.IsSelected = false;
            }

            // find TreeviewItem
            var treeViewItem = WpfTreeNavigation.TryFindParent <TreeViewItem>(cell);

            if (treeViewItem == null)
            {
                return;
            }

            // find textblock
            var tb = WpfTreeNavigation.TryFindChild <TextBlock>(treeViewItem);

            if (tb == null)
            {
                return;
            }

            // change visibility
            cell.Visibility = Visibility.Collapsed;
            tb.Visibility   = Visibility.Visible;
        }
Ejemplo n.º 5
0
        void MyList_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (WatchType != WatchListType.Watch)
            {
                return;
            }
            TreeViewItem treeViewItem = null;

            if (e.OriginalSource is TextBlock)
            {
                var tb = (TextBlock)e.OriginalSource;

                // find TreeviewItem
                treeViewItem = WpfTreeNavigation.TryFindParent <TreeViewItem>(tb);
                if (treeViewItem == null)
                {
                    return;
                }

                // try find TreeViewItem parent of the current node
                // if parent != null, we will not alow edit the value
                var treeViewItemParent = WpfTreeNavigation.TryFindParent <TreeViewItem>(treeViewItem, false);
                if (treeViewItemParent == null)
                {
                    // find cell
                    var cell = WpfTreeNavigation.TryFindChild <WatchListAutoCompleteCell>(treeViewItem);

                    // change visibility
                    tb.Visibility   = Visibility.Collapsed;
                    cell.Visibility = Visibility.Visible;
                    e.Handled       = true;
                }
            }

            if (!e.Handled)
            {
                ExpandChildren(SelectedNode, treeViewItem);
            }
        }
Ejemplo n.º 6
0
 static T TryFindChild <T>(DependencyObject root) where T : DependencyObject
 {
     return(WpfTreeNavigation.TryFindChild <T>(root));
 }