Skip to main content

UndoManager Class

Definition​

Assembly:Avalonia.Controls.Documents
Package:Avalonia.Controls.Documents

Manages undo/redo operations for a document. Set one on Avalonia.Controls.Documents.TextModel.TextDocument.UndoManager to record changes; leave that property , or set Avalonia.Controls.Documents.Undo.UndoManager.IsEnabled to , for a document that records nothing.

public class UndoManager

Inheritance: object -> UndoManager

Implements: IUndoHistory, IUndoManager, IDisposable

Constructors​

NameDescription
UndoManagerInitializes a new instance of Avalonia.Controls.Documents.Undo.UndoManager with the specified undo stack limit.

UndoManager Constructor​

Initializes a new instance of Avalonia.Controls.Documents.Undo.UndoManager with the specified undo stack limit.

public UndoManager(int undoLimit)

Parameters​

undoLimit int

Maximum number of undo units to retain.

Methods​

NameDescription
BeginUndoUnitNo summary available.
ClearClears all undo and redo history.
DisposeReleases resources by clearing the undo and redo history.
RecordRecords an externally created unit directly onto the undo stack.
RedoRedoes the most recently undone unit and returns it, or if nothing to redo.
UndoUndoes the most recent undo unit and returns it, or if nothing to undo.

BeginUndoUnit Method​

public Avalonia.Controls.Documents.Undo.IUndoScope BeginUndoUnit(string description, Nullable<Avalonia.Controls.Documents.Undo.SelectionSnapshot> selectionBefore)

Parameters​

description string

selectionBefore Nullable<Avalonia.Controls.Documents.Undo.SelectionSnapshot>

Returns​

Avalonia.Controls.Documents.Undo.IUndoScope

Clear Method​

Clears all undo and redo history.

public void Clear()

Dispose Method​

Releases resources by clearing the undo and redo history.

public void Dispose()

Record Method​

Records an externally created unit directly onto the undo stack.

public void Record(Avalonia.Controls.Documents.Undo.IUndoUnit unit)

Parameters​

unit Avalonia.Controls.Documents.Undo.IUndoUnit

The unit to record. It has to satisfy an internal contract, so a unit built outside this assembly is rejected. Group edits with Avalonia.Controls.Documents.Undo.UndoManager.BeginUndoUnit(string,Nullable{Avalonia.Controls.Documents.Undo.SelectionSnapshot}) instead.

Exceptions​

Redo Method​

Redoes the most recently undone unit and returns it, or if nothing to redo.

public Avalonia.Controls.Documents.Undo.IUndoUnit Redo()

Returns​

Avalonia.Controls.Documents.Undo.IUndoUnit

Undo Method​

Undoes the most recent undo unit and returns it, or if nothing to undo.

public Avalonia.Controls.Documents.Undo.IUndoUnit Undo()

Returns​

Avalonia.Controls.Documents.Undo.IUndoUnit

Properties​

NameDescription
CanRedoGets a value indicating whether there are actions available to redo.
CanUndoGets a value indicating whether there are actions available to undo.
IsEnabledGets or sets whether undo/redo tracking is active.
RedoUnitsA live, newest-first view of the redo stack. Backed by the internal buffer, so its contents change as units are recorded and replayed; do not cache it across a mutation.
UndoLimitGets or sets the maximum number of undo units to retain on the undo stack.
UndoUnitsA live, newest-first view of the undo stack. Backed by the internal buffer, so its contents change as units are recorded and replayed; do not cache it across a mutation.

CanRedo Property​

Gets a value indicating whether there are actions available to redo.

public bool CanRedo { get; set; }

CanUndo Property​

Gets a value indicating whether there are actions available to undo.

public bool CanUndo { get; set; }

IsEnabled Property​

Gets or sets whether undo/redo tracking is active.

public bool IsEnabled { get; set; }

RedoUnits Property​

A live, newest-first view of the redo stack. Backed by the internal buffer, so its contents change as units are recorded and replayed; do not cache it across a mutation.

public System.Collections.Generic.IReadOnlyList<Avalonia.Controls.Documents.Undo.IUndoUnit> RedoUnits { get; set; }

UndoLimit Property​

Gets or sets the maximum number of undo units to retain on the undo stack.

public int UndoLimit { get; set; }

UndoUnits Property​

A live, newest-first view of the undo stack. Backed by the internal buffer, so its contents change as units are recorded and replayed; do not cache it across a mutation.

public System.Collections.Generic.IReadOnlyList<Avalonia.Controls.Documents.Undo.IUndoUnit> UndoUnits { get; set; }

Events​

NameDescription
StateChangedRaised when the undo/redo state changes (e.g., after an action is recorded, undone, or redone).

StateChanged Event​

Raised when the undo/redo state changes (e.g., after an action is recorded, undone, or redone).

public event EventHandler StateChanged