Ejemplo n.º 1
0
        public void SetTree()
        {
            CloseAllGrid();
            TreeVis = Visibility.Visible;
            if (!_isChange)
            {
                ChangeColor();
            }
            BaseTreeVM vm = new BaseTreeVM()
            {
                DisplayText = "根节点", Children = new ObservableCollection <BaseTreeVM>()
            };

            for (int i = 1; i <= 10; i++)
            {
                BaseTreeVM cvm = new BaseTreeVM()
                {
                    DisplayText = "子节点" + i, Children = new ObservableCollection <BaseTreeVM>()
                };
                BaseTreeVM ccvm = new BaseTreeVM()
                {
                    DisplayText = "子子节点" + i
                };
                cvm.Children.Add(ccvm);
                vm.Children.Add(cvm);
            }
            TreeData = new ObservableCollection <BaseTreeVM>()
            {
                vm
            };
        }
Ejemplo n.º 2
0
        public void ClickNode(object sender, MouseButtonEventArgs e)
        {
            TextBlock  tb = sender as TextBlock;
            BaseTreeVM vm = tb.DataContext as BaseTreeVM;

            if (e.LeftButton == MouseButtonState.Pressed && e.ClickCount == 2)
            {
                MessageBox.Show("双击了" + vm.DisplayText, "提示");
            }
        }