Undo-Redo Frameworks For WPF and Silverlight

| by Roopesh Shenoy Follow 0 Followers on Jan 31, 2012. Estimated reading time: 1 minute |

Undo and Redo are two commands that are commonly expected by users in a rich interface and, when well implemented, can improve an application's usability significantly. However building the functionality from scratch for each application can be time-consuming and repetitive. At least two libraries exist that can help WPF and Silverlight developers - a recently announced Undo-Redo framework from Infragistics (CTP) and an open source library called Undo.

A common way to implement multiple-Undo-Redo functionality is to use the Command Pattern, keeping a stack of command objects for undo. For redo a second stack can have all the commands that are undone. However this simple technique can start getting complicated when you consider following things -

  • Collections need to be handled separately from Properties
  • Multiple commands might have to be bunched together – for eg, if you have a textbox bound to a model property, you don’t want each keystroke to be considered as a separate action, even if the model is wired to be updated on each keystroke

This is where undo frameworks can help. The framework from Infragistics provides several features as outlined in their announcement. This includes custom Undo-Units, support for ObservableCollection and Transaction Support. Similarly, there is also an open source framework called Undo, by Kirill Osenkov which supports nested transactions and action merging. You can learn more about this framework in Kirill’s article and in the project documentation. 

Note that these are linear undo-redo frameworks – they don’t support non-linear/branched undos (where the user can selectively undo any of the previous actions without undoing everything till that point). Even linear Undo-Redo scenarios can have user-experience challenges, especially when the user expects something to be undone, but that something hasn’t been recorded yet (for eg, user types in a textbox and on tabbing out a validation kicks in so the bound property is not updated) etc. 

Hopefully, we will continue to see more work in this area. 

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread


Educational Content

Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you