Custom node data - undo not working

Hi,

I have a custom node data class, with a node location property. My class has implemented INotifyPropertyChanged and is raising events with PropertyChangedEventArgs populated with the property name.

This by itself doesn’t seem to be enough to have the Undo working properly for the node position changes.

I a test application, what I found is that I have to raise the property change notification with Northwoods.GoXam.Model.ModelChangedEventArgs.

This is an issue for me because I inherited an existing data class that I am using for node data. If I have to raise property change notifications with GoXam event args then I guess I have to sub-class and re-implement all the property change notifications.

Is there a different way to get the Undo for node location to work properly?

Thanks

You can override …Model.HandleNodePropertyChanged.

If the EventArgs argument is not a ModelChangedEventArgs, and if the PropertyName isn’t one of the ones that the model already knows about such as the value of NodeKeyPath or NodeCategoryPath, then you can construct your own ModelChangedEventArgs and pass it to DiagramModel.OnChanged. You can do that for your Location property and any others that you want to have recorded for undo/redo. Of course you’ll need to pass along the previous or old value of the property as the ModelChangedEventArgs.OldValue.

Otherwise just call the base method.