Пример #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");
            }
        }
Пример #2
0
        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);
        }