Skip to main content

IInteractiveTextHost Interface

Definition​

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

Host interface for interactive text views that support selection, navigation, and modular components — but not necessarily editing.

public interface IInteractiveTextHost
Implements:ITextViewHost

Remarks​

This interface provides everything a read-only interactive view needs: document access, selection, component registration, and input scope. Read-only controls like Markdown and FlowDocumentScrollViewer implement this interface directly.

For editing support (text insertion, deletion, formatting), see ITextEditorHost which extends this interface with editing-specific members.

Methods​

NameDescription
ActivateDocumentMakes document the document the host's selection covers: a nested document of the main one (a page band, a footnote), or the main document itself when null. The selection moves to position when one is given. Components call this when a pointer they resolved belongs to another document than the selection's. Reading needs the switch as much as editing does, so the viewers answer it too; a host without nested documents declines and the move is dropped, which keeps a nested document's text unselectable there.
GetComponentNo summary available.
RegisterComponentRegisters a component with this host.
UnregisterComponentUnregisters a component from this host.

ActivateDocument Method​

Makes document the document the host's selection covers: a nested document of the main one (a page band, a footnote), or the main document itself when null. The selection moves to position when one is given. Components call this when a pointer they resolved belongs to another document than the selection's. Reading needs the switch as much as editing does, so the viewers answer it too; a host without nested documents declines and the move is dropped, which keeps a nested document's text unselectable there.

public bool ActivateDocument(Avalonia.Controls.Documents.TextModel.TextDocument document, Avalonia.Controls.Documents.TextModel.TextPointer position)

Parameters​

document Avalonia.Controls.Documents.TextModel.TextDocument

position Avalonia.Controls.Documents.TextModel.TextPointer

Returns​

bool

Whether the document is the active one afterwards.

GetComponent Method​

public T GetComponent<T>()

Type Parameters​

T

Returns​

T

RegisterComponent Method​

Registers a component with this host.

public void RegisterComponent(Avalonia.Controls.Documents.Primitives.Components.ITextViewComponent component)

Parameters​

component Avalonia.Controls.Documents.Primitives.Components.ITextViewComponent

The component to register.

Remarks​

If the host is already in the attached state, the component receives an immediate Avalonia.Controls.Documents.Primitives.Components.ITextViewComponent.OnAttach(Avalonia.Controls.Documents.Primitives.IInteractiveTextHost) callback.

UnregisterComponent Method​

Unregisters a component from this host.

public void UnregisterComponent(Avalonia.Controls.Documents.Primitives.Components.ITextViewComponent component)

Parameters​

component Avalonia.Controls.Documents.Primitives.Components.ITextViewComponent

The component to unregister.

Remarks​

If the component is currently attached, it receives an Avalonia.Controls.Documents.Primitives.Components.ITextViewComponent.OnDetach callback before removal.

Properties​

NameDescription
ActiveDocumentGets the nested document the selection is in (a page band or a footnote the caret entered), or null while the selection is in the main document. A host without nested documents always answers null.
SelectionGets the current text selection.
TextDocumentGets the underlying text document.
UIScopeGets the UI element scope for input handling (pointer events, etc.).

ActiveDocument Property​

Gets the nested document the selection is in (a page band or a footnote the caret entered), or null while the selection is in the main document. A host without nested documents always answers null.

public Avalonia.Controls.Documents.TextModel.TextDocument ActiveDocument { get; set; }

Selection Property​

Gets the current text selection.

public Avalonia.Controls.TextSelection Selection { get; set; }

TextDocument Property​

Gets the underlying text document.

public Avalonia.Controls.Documents.TextModel.TextDocument TextDocument { get; set; }

UIScope Property​

Gets the UI element scope for input handling (pointer events, etc.).

public Avalonia.Input.InputElement UIScope { get; set; }

Remarks​

This property returns the element that should be used as the scope for pointer/mouse event handling. This is typically a container that wraps the document area but excludes UI elements like toolbars.

Events​

NameDescription
ActiveDocumentChangedOccurs when Avalonia.Controls.Documents.Primitives.IInteractiveTextHost.ActiveDocument changes: the selection entered a page band or a footnote, or returned to the main document. A host without nested documents never raises it, but must still declare it - a component that follows the caret across documents has no other way to learn of the move, because a pure activation carries no selection change.
ContentChangedOccurs when the document content changes.
DocumentChangedOccurs when the document is replaced.
SelectionChangedOccurs when the selection changes.

ActiveDocumentChanged Event​

Occurs when Avalonia.Controls.Documents.Primitives.IInteractiveTextHost.ActiveDocument changes: the selection entered a page band or a footnote, or returned to the main document. A host without nested documents never raises it, but must still declare it - a component that follows the caret across documents has no other way to learn of the move, because a pure activation carries no selection change.

public event EventHandler ActiveDocumentChanged

Remarks​

Defaults to a no-op so a host written before this member existed still compiles. Such a host has no nested documents to move between, so there is nothing for it to raise.

ContentChanged Event​

Occurs when the document content changes.

public event EventHandler ContentChanged

DocumentChanged Event​

Occurs when the document is replaced.

public event EventHandler DocumentChanged

SelectionChanged Event​

Occurs when the selection changes.

public event EventHandler SelectionChanged