The undo manager acts as a mediator between commands, the diagram and the command history. It is represented by the UndoManager class, whose only instance can be accessed by the Diagram's UndoManager property.
By default, undo functionality is disabled - commands are executed, but are not recorded in history for later undo or redo. To enable undo, set UndoEnabled to true. You might need to disable undo before executing actions you don't want end-users to undo, for example creating special start/end nodes. Another situation in which you might want to disable undo is when creating programmatically a lot of new diagram items - say hundreds or thousands. WpfDiagram creates an undo record for each item creation; if the Capacity of the command history is smaller than the number of items created, most of the records will drop from the history queue while adding new ones. That would waste processing power and memory for creating undo records that won't be used.
As an alternative, you can create a composite record by calling StartComposite. All subsequent create-item actions are saved in the composite. The composite is saved in the undo history as a single record that allows undo or redo of all constituent actions as a single operation. StartComposite creates and returns a CompositeCmd instance, which is marked as active composite in the undo manager. While there is an active composite, all actions that are carried out are added to it. Call the Execute method of the active composite to stop recording subcommands in it and save it in the history as atomic undoable operation.
Use the Undo and Redo methods of the undo manager to undo or redo actions. Do not call the respective methods of the Command class - they are called internally by the undo manager, and in addition the current command history position is updated and the diagram view is repainted.