示例#1
0
        private void Label_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            Type itemType = typeof(TreeViewItem);

            UIElement child  = sender as UIElement;
            UIElement father = null;

            if (itemType != null)
            {
                father = (UIElement)child.GetVisualAncestor(itemType);
            }

            if (father != null)
            {
                MenuTreeItemViewModel item = ((TreeViewItem)father).DataContext as MenuTreeItemViewModel;
                if (item != null)
                {
                    if (item.TxbNameVisi == Visibility.Collapsed)
                    {
                        item.StartEditName();
                    }
                }
            }
        }
示例#2
0
        private void TextBox_LostFocus(object sender, RoutedEventArgs e)
        {
            Type itemType = typeof(TreeViewItem);

            UIElement child  = sender as UIElement;
            UIElement father = null;

            if (itemType != null)
            {
                father = (UIElement)child.GetVisualAncestor(itemType);
            }

            if (father != null)
            {
                MenuTreeItemViewModel item = ((TreeViewItem)father).DataContext as MenuTreeItemViewModel;
                if (item != null)
                {
                    if (item.TxbNameVisi == Visibility.Visible)
                    {
                        item.StopEditName();
                    }
                }
            }
        }