'Declaration Public Class UndoManager Inherits Infragistics.PropertyChangeNotifier
public class UndoManager : Infragistics.PropertyChangeNotifier
The UndoManager manages the undo and redo history. Operations are added to the undo/redo history by adding UndoUnit instances to it using one of the available methods. One can create an instance of a custom UndoUnit derived class or one of the classes included in this assembly and use the AddChange(UndoUnit) method. The UndoManager also exposes a number of helper methods that will create an UndoUnit and add it to the history. The AddPropertyChange overloads can be used to record the change of a property of some object. The AddCollectionChange overloads can be used to record a change to an collection implementing ICollection>T<. The remaining AddChange overloads may be used to provide a set of delegates representing the Undo and Redo actions that should be taken when the manager is performing an undo or redo operation. These methods using the UndoUnitFactoryResolved so if you want to change the UndoUnit type that is created by these methods you may derive a class from UndoUnitFactory and set the UndoUnitFactory property to an instance of that class.
The UndoHistory and RedoHistory are read-only collections of UndoHistoryItem instances. UndoHistoryItem exposes the root UndoUnit that represents the operation to be performed as well as short and long descriptions of the operation. These collections implement INotifyCollectionChanged and therefore can be used in your UI as the source for menu, etc. that would display the history to the end user.
The Undo and Redo methods are used to perform an undo or redo operation. When these methods are invoked a UndoHistoryItem is removed from the associated history (e.g. UndoHistory) and then the UndoUnit.Execute method of the UndoHistoryItem.Unit is invoked. It is important to realize that by default UndoUnits are not automatically moved to the opposite history. For example, while undoing a property change it is expected that the property change will result in a new call to the AddPropertyChange overload. That would create a new undo unit representing that change and add it to the UndoManager's history. In that case, since the UndoManager was in the process of performing an undo, the new UndoUnit would be added to the redo history.
The UndoManager exposes a number of read-only boolean properties which indicate the current state of the object. The IsPerformingUndo and IsPerformingRedo are true while performing an undo or redo respectively. The CanUndo and CanRedo properties indicate if there are any items in the undo/redo history.
When performing discrete initialization, one can use the Suspend method to temporarily disable logging of the UndoUnits in the history. Any calls to AddChange are ignored until the Resume method is invoked. The Resume method must be invoked once for each time that the Suspend method is invoked. The IsSuspended property will return true between the calls to Suspend and Resume.
The UndoManager provides support for merging of a new UndoUnit with the most recent UndoUnit that was stored. This is useful in cases where the same action is occuring multiple times. For example while dragging the thumb of a Slider and therefore the property that is bound to the Slider's Value. Merging may be disabled indefinitely by setting the AllowMerging to false. One can also suppress the merging of the current item by invoking the PreventMerge method.
When multiple operations should be treated as a single undoable action, one can use transactions. The UndoManager provides support for transactions using the StartTransaction(String,String) method. This returns a UndoTransaction instance. Any subsequent units that are added to the UndoManager are stored within that transaction until the transaction has been committed (see UndoTransaction.Commit) or rolled back (see UndoTransaction.Rollback. Nested transactions are supported so calling StartTransaction while a transaction is progress will add that to the UndoTransaction.Units of the CurrentTransaction. One can get access to the current open transaction, if there is one, using the RootTransaction property. Also, if there is a block of code that you want to execute within a transaction, you may use the ExecuteInTransaction(String,String,Action) method. This method will take care of calling the Rollback method of the transaction it creates if an exception occurs (without preventing the exception from bubbling up). Otherwise it will invoke the Commit of the transaction. When the RootTransaction has been committed it is then added to the undo or redo history depending on the current state of the UndoManager.
Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2