Commands and Undo / Redo

Oct 8, 2008 at 4:51 PM
I'm new to most of this, but i've got really far with this guidance.

Has anyone got any good ideas about implementing undo / redo?

My prototype has one data model, with five presenter / view pairs corresponding to five regions. I'm looking at delegate commands in the presenters which are executed by the xaml views. This is fine for UI only interactions, but sometimes I want to effect the data back in the data model.

So i am intending to use Composite commands, like in the RI. The presenters will add their commands to these composite commands. The xaml views will refer to these composite commands.  Then i'm guessing that i will need a undo / redo controller of some sort that will add it's own delegate commands to these composite commands. This controller will maintain a stack of commands and do/undo/redo them against the model.

Anyone got any helpful advice?


Jan 30, 2009 at 2:22 AM
I was getting to a point in my application where I'm starting to think of my strategy for undo / redo.

I was thinking it would make sense to subclass the DelegateCommand and / or RoutedUICommand and add an "undo" method, and use a "command manager" class to manage the stack of commands.

But then I was thinking of RoutedUICommands that are bound to built-in objects (such as the RichTextBox builtin command binding for the Copy / Cut / Paste / Delete, etc commands)

Does anyone have any thoughts on coming up with an architecture to support undo / redo?