- 2 minutes to read
The Layout Control provides the built-in support for multiple Undo/Redo. When an end-user changes the layout, the Layout Control tracks the changes within the layout via its Undo Manager. The end-user can then perform undo or redo operations by clicking the Undo and Redo buttons within the Customization Form. It's also possible to perform undo and redo operations in code using the methods provided by the Undo Manager.
The Undo Manager (LayoutControl.UndoManager) tracks the changes made by an end-user within the Layout Control. It stores all the changes within the undo stack. Each time an end-user changes the layout a new element that represents the previous layout serialization memory dump is appended to the undo stack. When an Undo operation is performed, the current position in the undo stack is moved to the left. The Redo operation moves the current position to the right. When performing Undo/Redo operations the Undo Manager restores the layout from the element at the current position within the undo stack.
This mechanism is illustrated in the image below:
The Undo Manager provides the methods and properties that allow you to identify whether the undo or redo operation can be performed, perform these operations manually, clear the undo stack. All these properties and methods are described in the table below:
|IsUndoAllowed||Indicates whether the Undo operation can be performed. This operation isn't available if the layout hasn't been changed yet by an end-user.|
|IsRedoAllowed||Indicates whether the Redo operation can be performed. This operation is available only after the Undo operation(s) has been performed.|
|Undo||Performs the Undo operation.|
|Redo||Performs the Redo operation.|
|Reset||Clears the undo stack.|
|UndoStackChanged||Occurs after the layout has been changed by an end-user and this change has been tracked by the undo manager (a new element has been added to the undo stack). Note this event isn't raised after the Undo or Redo operation has been performed.|