RichTextEditor Class
Definition
A rich text editor control that provides interactive editing capabilities for FlowDocument content.
public class RichTextEditor
Remarks
RichTextEditor is a full-featured text editing control that combines document rendering (TextViewBase) with interactive editing capabilities (text selection, keyboard input, mouse input, etc.).
Implements Avalonia.Controls.Documents.Primitives.ITextViewHost for viewport/scrolling and Avalonia.Controls.Documents.Primitives.ITextEditorHost for editing component abstraction.
Constructors
| Name | Description |
|---|---|
| RichTextEditor | Initializes a new instance of the Avalonia.Controls.RichTextEditor control. |
RichTextEditor Constructor
Initializes a new instance of the Avalonia.Controls.RichTextEditor control.
public RichTextEditor()
Methods
| Name | Description |
|---|---|
| ActivateDocument | Makes document the document the editor edits: one of the body's page bands, or the body itself when null. A band's selection is created the first time the band is entered and kept while the band belongs to the document; the body's selection stays where it was. The caret moves to position when one is given, and the view brings the document's placement into view. Returns false for a document that is neither the body nor one of its bands. |
| AddHandler (2 overloads) | Adds a handler for the specified routed event. Inherited from Interactive. |
| ApplyStyling | Applies styling to the control if the control is initialized and styling is not already applied. Inherited from StyledElement. |
| ApplyTemplate | Creates the visual children of the control, if necessary Inherited from TemplatedControl. |
| Arrange | Arranges the control and its children. Inherited from Layoutable. |
| BeginInit | Inherited from StyledElement. |
| Bind (8 overloads) | Binds a Avalonia.AvaloniaProperty to an Avalonia.Data.BindingBase. Inherited from AvaloniaObject. |
| CheckAccess | Returns a value indicating whether the current thread is the UI thread. Inherited from AvaloniaObject. |
| ClearSelection | Clears the current selection. |
| ClearUndoHistory | Clears the undo and redo history. |
| ClearValue (4 overloads) | Clears a Avalonia.AvaloniaProperty's local value. Inherited from AvaloniaObject. |
| CoerceValue | Coerces the specified Avalonia.AvaloniaProperty. Inherited from AvaloniaObject. |
| EndInit | Inherited from StyledElement. |
| Equals | Compares two objects using reference equality. Inherited from AvaloniaObject. |
| Focus | Focuses the control. Inherited from InputElement. |
| GetBaseValue | Inherited from AvaloniaObject. |
| GetComponent | No summary available. |
| GetFlowDirection | Gets the value of the attached Avalonia.Visual.FlowDirectionProperty on a control. Inherited from Visual. |
| GetHashCode | Gets the hash code for the object. Inherited from AvaloniaObject. |
| GetIsHoldingEnabled | Inherited from InputElement. |
| GetIsHoldWithMouseEnabled | Inherited from InputElement. |
| GetIsTemplateFocusTarget | Gets the value of the IsTemplateFocusTargetProperty attached property on a control. Inherited from TemplatedControl. |
| GetValue (3 overloads) | Gets a Avalonia.AvaloniaProperty value. Inherited from AvaloniaObject. |
| InvalidateArrange | Invalidates the arrangement of the control and queues a new layout pass. Inherited from Layoutable. |
| InvalidateMeasure | Invalidates the measurement of the control and queues a new layout pass. Inherited from Layoutable. |
| InvalidateVisual | Invalidates the visual and queues a repaint. Inherited from Visual. |
| IsAnimating | Checks whether a Avalonia.AvaloniaProperty is animating. Inherited from AvaloniaObject. |
| IsSet | Checks whether a Avalonia.AvaloniaProperty is set on this object. Inherited from AvaloniaObject. |
| Load | Loads a document from a stream. |
| LoadAsync | Loads a document from a stream asynchronously. |
| Measure | Carries out a measure of the control. Inherited from Layoutable. |
| RaiseEvent | Raises a routed event. Inherited from Interactive. |
| Redo | Redoes the most recently undone editing operation. |
| RegisterComponent | Registers a component with this host. |
| RemoveHandler (2 overloads) | Removes a handler for the specified routed event. Inherited from Interactive. |
| Render | Renders the visual to a Avalonia.Media.DrawingContext. Inherited from Visual. |
| Save | Saves the document to a stream. |
| SaveAsync | Saves the document to a stream asynchronously on a background thread. |
| Select | Sets the selection to the specified range. |
| SelectAll | Selects all text in the document. |
| SetCurrentValue (2 overloads) | Sets the value of a dependency property without changing its value source. Inherited from AvaloniaObject. |
| SetFlowDirection | Sets the value of the attached Avalonia.Visual.FlowDirectionProperty on a control. Inherited from Visual. |
| SetIsHoldingEnabled | Inherited from InputElement. |
| SetIsHoldWithMouseEnabled | Inherited from InputElement. |
| SetIsTemplateFocusTarget | Sets the value of the IsTemplateFocusTargetProperty attached property on a control. Inherited from TemplatedControl. |
| SetValue (3 overloads) | Sets a Avalonia.AvaloniaProperty value. Inherited from AvaloniaObject. |
| TryGetResource | Inherited from StyledElement. |
| Undo | Undoes the most recent editing operation. |
| UnregisterComponent | Unregisters a component from this host. |
| UpdateLayout | Executes a layout pass. Inherited from Layoutable. |
| VerifyAccess | Checks that the current thread is the UI thread and throws if not. Inherited from AvaloniaObject. |
ActivateDocument Method
Makes document the document the editor edits: one of the
body's page bands, or the body itself when null. A band's selection is
created the first time the band is entered and kept while the band belongs
to the document; the body's selection stays where it was. The caret moves to
position when one is given, and the view brings the
document's placement into view. Returns false for a document that is neither
the body nor one of its bands.
public bool ActivateDocument(Avalonia.Controls.Documents.FlowDocument document, Avalonia.Controls.Documents.TextModel.TextPointer position)
Parameters
document Avalonia.Controls.Documents.FlowDocument
position Avalonia.Controls.Documents.TextModel.TextPointer
Returns
bool
ClearSelection Method
Clears the current selection.
public void ClearSelection()
ClearUndoHistory Method
Clears the undo and redo history.
public void ClearUndoHistory()
GetComponent Method
public T GetComponent<T>()
Type Parameters
T
Returns
T
Load Method
Loads a document from a stream.
public void Load(System.IO.Stream stream, Avalonia.Controls.Documents.Serialization.IDocumentSerializer serializer)
Parameters
stream System.IO.Stream
The stream to read from.
serializer Avalonia.Controls.Documents.Serialization.IDocumentSerializer
The serializer to use.
Remarks
Parses and builds the document on the calling thread. Prefer Avalonia.Controls.RichTextEditor.LoadAsync(System.IO.Stream,Avalonia.Controls.Documents.Serialization.IDocumentSerializer,System.Threading.CancellationToken) for a large document, which keeps the parse off it.
Exceptions
LoadAsync Method
Loads a document from a stream asynchronously.
public System.Threading.Tasks.Task LoadAsync(System.IO.Stream stream, Avalonia.Controls.Documents.Serialization.IDocumentSerializer serializer, System.Threading.CancellationToken cancellationToken)
Parameters
stream System.IO.Stream
The stream to read from.
serializer Avalonia.Controls.Documents.Serialization.IDocumentSerializer
The serializer to use.
cancellationToken System.Threading.CancellationToken
Cancellation token.
Returns
System.Threading.Tasks.Task
A task that completes when the load is finished.
Remarks
This delegates to Avalonia.Controls.Documents.FlowDocument.LoadAsync(System.IO.Stream,Avalonia.Controls.Documents.Serialization.IDocumentSerializer,System.Threading.CancellationToken).
Exceptions
Redo Method
Redoes the most recently undone editing operation.
public void Redo()
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.
Save Method
Saves the document to a stream.
public void Save(System.IO.Stream stream, Avalonia.Controls.Documents.Serialization.IDocumentSerializer serializer)
Parameters
stream System.IO.Stream
The stream to write to.
serializer Avalonia.Controls.Documents.Serialization.IDocumentSerializer
The serializer to use.
Remarks
Writes on the calling thread. Prefer Avalonia.Controls.RichTextEditor.SaveAsync(System.IO.Stream,Avalonia.Controls.Documents.Serialization.IDocumentSerializer,System.Threading.CancellationToken) for a large document, which keeps the write off it.
Exceptions
SaveAsync Method
Saves the document to a stream asynchronously on a background thread.
public System.Threading.Tasks.Task SaveAsync(System.IO.Stream stream, Avalonia.Controls.Documents.Serialization.IDocumentSerializer serializer, System.Threading.CancellationToken cancellationToken)
Parameters
stream System.IO.Stream
The stream to write to.
serializer Avalonia.Controls.Documents.Serialization.IDocumentSerializer
The serializer to use.
cancellationToken System.Threading.CancellationToken
Cancellation token.
Returns
System.Threading.Tasks.Task
A task that completes when the save is finished.
Remarks
This is a convenience method that delegates to Avalonia.Controls.Documents.FlowDocument.SaveAsync(System.IO.Stream,Avalonia.Controls.Documents.Serialization.IDocumentSerializer,System.Threading.CancellationToken).
Exceptions
Select Method
Sets the selection to the specified range.
public void Select(Avalonia.Controls.Documents.TextModel.TextPointer start, Avalonia.Controls.Documents.TextModel.TextPointer end)
Parameters
start Avalonia.Controls.Documents.TextModel.TextPointer
The start position of the selection.
end Avalonia.Controls.Documents.TextModel.TextPointer
The end position of the selection.
SelectAll Method
Selects all text in the document.
public void SelectAll()
Undo Method
Undoes the most recent editing operation.
public void Undo()