About CancelViewModel

Aug 16, 2011 at 5:27 PM

It seems that invoking CancelViewModel seems to work only one time... for example:
I have an UNDO button , I make some changes to the model... then click the UNDO button, changes are rolled back properly...
I make new changes and again I press the UNDO button, but this time seems not to have effect on my model's data.
Can u check/explay about this behavior? (Working Under Catel 1.4)

Aug 16, 2011 at 5:28 PM

Canceling a view model means that the view model is about to be closed and will cancel all models implementing IEditableObject. If you want to implement custom redo/undo for models, the following is advised:


1) Create an Undo command (you probably already have this)
2) In the Undo, cast the model to IEditableObject, call CancelEdit and immediately call BeginEdit again.

This way, you won't break existing behaviors, and get exactly what you need.