示例#1
0
        private void UpdateTreeViewItemViewModel()
        {
            if (!shouldUpdateViewModel)
            {
                return;
            }

            if (this.Header is TreeViewItemModelItemViewModel)
            {
                TreeViewItemModelItemViewModel modelItemViewModel = (TreeViewItemModelItemViewModel)this.Header;
                if (modelItemViewModel.HasDesigner)
                {
                    HighlightModelItemOnDesigner(modelItemViewModel.VisualValue);
                }
                else
                {
                    HighlightTreeViewItemAndClearSelectionOnDesigner(modelItemViewModel);
                }
            }
            else if (this.Header is TreeViewItemModelPropertyViewModel)
            {
                TreeViewItemModelPropertyViewModel modelPropertyViewModel = (TreeViewItemModelPropertyViewModel)this.Header;
                HighlightTreeViewItemAndClearSelectionOnDesigner(modelPropertyViewModel);
            }
            else if (this.Header is TreeViewItemKeyValuePairModelItemViewModel)
            {
                TreeViewItemKeyValuePairModelItemViewModel keyValuePairItem = (TreeViewItemKeyValuePairModelItemViewModel)this.Header;
                HighlightTreeViewItemAndClearSelectionOnDesigner(keyValuePairItem);
            }
            else
            {
                Fx.Assert("Invaild logic if Header is not TreeViewItemModelItemViewModel/TreeViewItemModelPropertyViewModel/TreeViewItemDictionaryModelItemViewModel");
            }
        }
        internal static TreeViewItemViewModel CreateViewModel(TreeViewItemViewModel parent, object value)
        {
            TreeViewItemViewModel viewModel = null;

            if (typeof(ModelItem).IsAssignableFrom(value.GetType()))
            {
                viewModel = new TreeViewItemModelItemViewModel(parent, value as ModelItem);
            }
            else if (typeof(ModelProperty).IsAssignableFrom(value.GetType()))
            {
                viewModel = new TreeViewItemModelPropertyViewModel(parent, value as ModelProperty);
            }
            else if (typeof(KeyValuePair <ModelItem, ModelItem>).IsAssignableFrom(value.GetType()))
            {
                viewModel = new TreeViewItemKeyValuePairModelItemViewModel(parent, (KeyValuePair <ModelItem, ModelItem>)value);
            }
            return(viewModel);
        }
示例#3
0
        private bool IsModelPropertyNodeExisted(ModelProperty property)
        {
            bool isModelPropertyNodeExisted = false;

            foreach (TreeViewItemViewModel viewModel in Children)
            {
                TreeViewItemModelPropertyViewModel modelPropertyViewModel = viewModel as TreeViewItemModelPropertyViewModel;
                if (modelPropertyViewModel != null)
                {
                    if (modelPropertyViewModel.Value == property)
                    {
                        isModelPropertyNodeExisted = true;
                        break;
                    }
                }
            }

            return(isModelPropertyNodeExisted);
        }