Skip to main content

DocumentChangedEventArgs Class

Definition​

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

Raised via Avalonia.Controls.Documents.TextModel.TextDocument.Changed when an outermost Avalonia.Controls.Documents.TextModel.TextDocument.BeginChange scope completes after producing at least one observable change. Suppressed entirely on empty / no-op scopes — handlers can rely on the event meaning "something changed."

public class DocumentChangedEventArgs

Inheritance: EventArgs -> DocumentChangedEventArgs

Remarks​

One Avalonia.Controls.Documents.TextModel.DocumentChangedEventArgs aggregates every Avalonia.Controls.Documents.TextModel.TextChangeEventArgs that fired in the same scope, in invocation order. The aggregate is the right hook for batch-aware consumers (autosave, replication, status updates); per-edit consumers can keep using Avalonia.Controls.Documents.TextModel.TextDocument.TextChanged.

Avalonia.Controls.Documents.TextModel.DocumentChangedEventArgs.Origin and Avalonia.Controls.Documents.TextModel.DocumentChangedEventArgs.UndoUnit let consumers correlate the commit with the undo/redo system. See the Avalonia.Controls.Documents.TextModel.ChangeOrigin documentation for the four scenarios.

Properties​

NameDescription
HasChangesTrue when the scope produced at least one change. Always when this event fires — empty scopes are suppressed entirely. Reserved for future use when structure-only mutations may broaden the meaning of "changed."
OriginIndicates whether this commit is a normal edit, an undo replay, or a redo replay. Use this to skip pushing replays into a replication log or autosave queue.
TextChangesAll text changes recorded during the scope, in invocation order. Read-only; the underlying buffer is the recorder's storage.
UndoUnitThe undo unit involved in this commit, or when undo is disabled or no unit was opened. For Avalonia.Controls.Documents.TextModel.ChangeOrigin.Edit this is the unit just committed to the undo stack; for Avalonia.Controls.Documents.TextModel.ChangeOrigin.Undo / Avalonia.Controls.Documents.TextModel.ChangeOrigin.Redo it is the unit being replayed.

HasChanges Property​

True when the scope produced at least one change. Always when this event fires — empty scopes are suppressed entirely. Reserved for future use when structure-only mutations may broaden the meaning of "changed."

public bool HasChanges { get; set; }

Origin Property​

Indicates whether this commit is a normal edit, an undo replay, or a redo replay. Use this to skip pushing replays into a replication log or autosave queue.

public Avalonia.Controls.Documents.TextModel.ChangeOrigin Origin { get; set; }

TextChanges Property​

All text changes recorded during the scope, in invocation order. Read-only; the underlying buffer is the recorder's storage.

public System.Collections.Generic.IReadOnlyList<Avalonia.Controls.Documents.TextModel.TextChangeEventArgs> TextChanges { get; set; }

UndoUnit Property​

The undo unit involved in this commit, or when undo is disabled or no unit was opened. For Avalonia.Controls.Documents.TextModel.ChangeOrigin.Edit this is the unit just committed to the undo stack; for Avalonia.Controls.Documents.TextModel.ChangeOrigin.Undo / Avalonia.Controls.Documents.TextModel.ChangeOrigin.Redo it is the unit being replayed.

public Avalonia.Controls.Documents.Undo.IUndoUnit UndoUnit { get; set; }