Is it possible to temporarily change a Part’s Data property value to another object in order to give the part a different visual appearance or part behaviour?
My intent is to take an existing Node Part and wrap it’s Data value into an adorner object, thereby giving it a diffrent visual appearance or behaviour. The adorner object is a subclass of the original node data class. The adorner class add additional properties or behaviours. The adorner object will not be part of the diagram model as it simply wraps the original node data object (which is part of the model).
I have a DataTemplateDictionary where each of the adorner types have their own DataTemplate within the dictionary.
Is what I’m trying to achieve possible? If so, is it also possible that these part changes are not undoable/redoable by the UndoManager?
I haven’t tried this, but I am concerned that replacing the Part.Data will confuse the PartManager about which model data is associated with which Part.
Could you instead add a property to your node data? Maybe it would be null normally but would be some adorner information otherwise. You would still change the node data’s Category, as it appears that you were intending to do.
Your suggestion is basically what I decided to implement after I submitted the post. I added an Adorner property to the node’s data class and I use that to extend the class when needed by manipulating the Category value of the node via the current Adorner object.
FYI, I tried changing the Part’s Data property value but it seemed to have no effect at all. I’m guessing because the Data property doesn’t appear to be a DependencyProperty.