How can I cancel a user's WPF TreeView click?

后端 未结 9 1968
长情又很酷
长情又很酷 2020-12-14 03:56

I\'ve got a WPF application with a Treeview control.

When the user clicks a node on the tree, other TextBox, ComboBox, etc. controls on the page are populated with a

9条回答
  •  北荒
    北荒 (楼主)
    2020-12-14 04:31

    CAMS_ARIES:

    XAML:

    code :

      private bool ManejarSeleccionNodoArbol(Object origen)
        {
            return true;  // with true, the selected nodo don't change
            return false // with false, the selected nodo change
        }
    
    
        private void Arbol_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {            
            if (e.Source is TreeViewItem)
            {
                e.Handled = ManejarSeleccionNodoArbol(e.Source);
            }
        }
    
        private void Arbol_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Source is TreeViewItem)
            {
               e.Handled=ManejarSeleccionNodoArbol(e.Source);
            }
        }         
    

提交回复
热议问题