1 //-----------------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //-----------------------------------------------------------------------------
5 namespace System.Activities.Presentation.Model
9 /// FakeModelItemImpl - purpose of this class is to allow full model editing expirience, without need to participate within model tree operations
10 /// If you use this class, even though it contains reference to ModelTreeManager, you are not affecting actual model tree. Any changes made to the
11 /// model, do not result in any undo/redo operations
12 /// see aslo DesignObjectWrapper class for more usage details
14 sealed class FakeModelItemImpl : ModelItemImpl
16 public FakeModelItemImpl(ModelTreeManager modelTreeManager, Type itemType, object instance, FakeModelItemImpl parent)
17 : base(modelTreeManager, itemType, instance, parent)
21 public override ModelItem Root
25 if (this.Parent == null)
31 return this.Parent.Root;
36 protected override void OnPropertyChanged(string propertyName)
38 IModelTreeItem modelTreeItem = (IModelTreeItem)this;
39 ModelItem currentValue;
40 //if property value has changed - remove existing value, so the ModelPropertyImplementation will
41 //force reading the value from the underlying object
42 if (modelTreeItem.ModelPropertyStore.TryGetValue(propertyName, out currentValue))
44 IModelTreeItem valueAsTreeItem = (IModelTreeItem)currentValue;
46 valueAsTreeItem.RemoveParent(this);
47 valueAsTreeItem.RemoveSource(this.Properties[propertyName]);
49 modelTreeItem.ModelPropertyStore.Remove(propertyName);
51 base.OnPropertyChanged(propertyName);