#934 – TextBox Has Built-In Undo Functionality

The TextBox control in WPF has built-in Undo and Redo functionality, allowing you to undo changes to the content of the TextBox or to re-apply (redo) changes that you’ve undone.

Assume that you have a TextBox with some text:


Now assume that you double-click to select the first word and then press Delete to delete it.


Do this two more times, so that you’ve delete the first three words of the text, one at a time.


You’ve now made three distinct changes to the text in the TextBox, one at a time.  You can delete the most recent change by pressing Ctrl+Z, which executes an undo operation.  This will restore the word that was most recently deleted.


You can press Ctrl+Z two more times, restoring the other words that you deleted.


You can redo a change (e.g. delete a word) by pressing Ctrl+Y.