//设置子节点的可见性,checkbox
 public void SetModelVisible(UnityTreeModel root, bool visible)
 {
     root.visible = visible;
     if (root.childs != null)
     {
         foreach (UnityTreeModel model in root.childs)
         {
             SetModelVisible(model, visible);
         }
     }
 }
 public string GetFullPath(UnityTreeModel model)
 {
     if (model.parent == null)
     {
         return(model.Name);
     }
     else
     {
         return(GetFullPath(model.parent) + "/" + model.Name);
     }
 }
 public void SetChildVisble(UnityTreeModel model)
 {
     model.visible = false;
     if (model.childs != null)
     {
         foreach (UnityTreeModel _model in model.childs)
         {
             SetChildVisble(_model);
         }
     }
 }
        private void treeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            UnityTreeModel model = treeView.SelectedItem as UnityTreeModel;

            SelectLayerName = "";
            while (null != model)
            {
                SelectLayerName = SelectLayerName == "" ? model.Name : model.Name + "/" + SelectLayerName;
                model           = model.parent;
            }
        }
        //图层显示开关
        private void CheckBox_Click(object sender, RoutedEventArgs e)
        {
            CheckBox         checkBox = sender as CheckBox;
            DependencyObject parent   = VisualTreeHelper.GetParent(VisualTreeHelper.GetParent(checkBox)); //找到chkbox的ContentPresenter
            ContentPresenter tvi      = parent as ContentPresenter;

            if (tvi != null)
            {
                List <UnityTreeModel> list   = treeView.ItemsSource as List <UnityTreeModel>;
                UnityTreeModel        node   = tvi.DataContext as UnityTreeModel;
                TreeViewItem          tvitem = FindTreeViewItemContainer(treeView, node);
                tvitem.IsSelected = true;

                SetModelVisible(node, checkBox.IsChecked.Value);
                SetObjShowStateMessage message = new SetObjShowStateMessage();
                message.path   = GetFullPath(node);
                message.iSShow = checkBox.IsChecked.Value;
                (view3d.view as U3dViewModel).ExcuteCommand(message);
            }
        }