Search
Undo and Redo

If the undoEnabled property is set to true, the control records users actions and allows undoing them later. The records are stored in a list, and can be undone consecutively by calling the undo method. An action that has been undone can be redone by calling the redo method. You can enable or disable UI elements that undo or redo commands by binding them to the canUndo and canRedo properties.

The control also runs and saves in the undo history AddItemCommand and RemoveItemCommand commands when items are programmatically added or removed from the Items collection of the Diagram. No other changes are recorded automatically when done from code. If support for undo/redo of such changes is required, they must be done through the executeCommand method.

To allow undoing changes of DiagramItem properties, create a ChangeItemCommand instance before setting the property values, and call executeCommand afterwards. Any other types of undoable changes can be implemented by deriving from the Command class and overriding its execute, undo and redo methods.