UndoManager Class
Definition
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
Constructors
| Name | Description |
|---|---|
| UndoManager | Initializes 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
| Name | Description |
|---|---|
| BeginUndoUnit | No summary available. |
| Clear | Clears all undo and redo history. |
| Dispose | Releases resources by clearing the undo and redo history. |
| Record | Records an externally created unit directly onto the undo stack. |
| Redo | Redoes the most recently undone unit and returns it, or if nothing to redo. |
| Undo | Undoes 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
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
Undo Method
Undoes the most recent undo unit and returns it, or if nothing to undo.
public Avalonia.Controls.Documents.Undo.IUndoUnit Undo()
Returns
Properties
| Name | Description |
|---|---|
| CanRedo | Gets a value indicating whether there are actions available to redo. |
| CanUndo | Gets a value indicating whether there are actions available to undo. |
| IsEnabled | Gets or sets whether undo/redo tracking is active. |
| RedoUnits | 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. |
| UndoLimit | Gets or sets the maximum number of undo units to retain on the undo stack. |
| UndoUnits | 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. |
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
| Name | Description |
|---|---|
| StateChanged | Raised 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