IInteractiveTextHost Interface
Definition
Host interface for interactive text views that support selection, navigation, and modular components — but not necessarily editing.
public interface IInteractiveTextHost
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
| Name | Description |
|---|---|
| ActivateDocument | 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. |
| GetComponent | No summary available. |
| RegisterComponent | Registers a component with this host. |
| UnregisterComponent | Unregisters 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
| Name | Description |
|---|---|
| ActiveDocument | 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. |
| Selection | Gets the current text selection. |
| TextDocument | Gets the underlying text document. |
| UIScope | Gets 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
| Name | Description |
|---|---|
| ActiveDocumentChanged | 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. |
| ContentChanged | Occurs when the document content changes. |
| DocumentChanged | Occurs when the document is replaced. |
| SelectionChanged | Occurs 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