Table of Contents

Class RichTextSelection

Namespace
RichEdit.Maui
Assembly
RichEdit.Maui.dll

Represents one editor's current selection, typing formats, and selection commands.

public sealed class RichTextSelection : INotifyPropertyChanged
Inheritance
RichTextSelection
Implements
Inherited Members

Properties

Active

Gets the caret endpoint.

public int Active { get; }

Property Value

int

Anchor

Gets the fixed endpoint.

public int Anchor { get; }

Property Value

int

CharacterFormat

Gets the live bindable character-format facade.

public RichTextSelectionCharacterFormat CharacterFormat { get; }

Property Value

RichTextSelectionCharacterFormat

ParagraphFormat

Gets the live bindable paragraph-format facade.

public RichTextSelectionParagraphFormat ParagraphFormat { get; }

Property Value

RichTextSelectionParagraphFormat

Range

Gets the current UTF-16 document range.

public TextSpan Range { get; }

Property Value

TextSpan

State

Gets the anchor and active endpoints.

public TextSelectionState State { get; }

Property Value

TextSelectionState

Text

Gets the selected logical plain text.

public string Text { get; }

Property Value

string

TypingCharacterFormat

Gets the declared character format used by newly typed text.

public RichTextCharacterFormat TypingCharacterFormat { get; }

Property Value

RichTextCharacterFormat

TypingParagraphFormat

Gets the paragraph format used by newly typed text.

public RichTextParagraphFormat TypingParagraphFormat { get; }

Property Value

RichTextParagraphFormat

Methods

ChangeListLevel(int)

Changes selected list levels by a signed delta. Outdenting the first level removes list state; indenting past the final definition level repeats its caller-defined marker style and layout progression.

public void ChangeListLevel(int delta)

Parameters

delta int

The signed nesting-level adjustment.

ClearList()

Removes list state from selected paragraphs.

public void ClearList()

Edit(Action<RichTextDocumentEdit>, TextSelectionState, RichTextEditOptions)

Applies an atomic editor action with an explicit resulting selection.

public void Edit(Action<RichTextDocumentEdit> edit, TextSelectionState selectionAfter, RichTextEditOptions options = default)

Parameters

edit Action<RichTextDocumentEdit>

The content edits.

selectionAfter TextSelectionState

The selection in the resulting document.

options RichTextEditOptions

History and application metadata.

InsertField(string, string)

Replaces selected content with a field result.

public void InsertField(string instruction, string result)

Parameters

instruction string

The RTF field instruction.

result string

The visible field result.

InsertImage(RichTextImage)

Replaces selected content with one inline image.

public void InsertImage(RichTextImage image)

Parameters

image RichTextImage

The owned image value.

Removes hyperlinks intersecting the selection.

public void RemoveLinks()

ReplaceFragment(RichTextDocumentFragment)

Replaces selected content with a portable rich fragment.

public void ReplaceFragment(RichTextDocumentFragment fragment)

Parameters

fragment RichTextDocumentFragment

The fragment to insert.

ReplaceText(string?)

Replaces selected content and collapses the caret after the insertion.

public void ReplaceText(string? text)

Parameters

text string

The replacement text. Null is treated as empty.

RestartList(int)

Restarts selected numbered-list items at a positive value.

public void RestartList(int startAt)

Parameters

startAt int

The new positive counter value.

Select(TextSelectionState)

Sets a directional selection, clamped to the document.

public void Select(TextSelectionState selection)

Parameters

selection TextSelectionState

The new selection.

Select(TextSpan)

Moves the selection to a validated document range.

public void Select(TextSpan range)

Parameters

range TextSpan

The new range.

Creates or replaces a hyperlink over the selection.

public void SetLink(string target, string? toolTip = null)

Parameters

target string

The application-defined target.

toolTip string

An optional RTF tooltip.

SetList(RichTextListDefinition, int)

Creates and applies an explicitly defined list.

public void SetList(RichTextListDefinition definition, int level = 0)

Parameters

definition RichTextListDefinition

The complete caller-defined list.

level int

The zero-based level to apply.

SetList(RichTextListId, int)

Continues an existing document list at a nesting level.

public void SetList(RichTextListId listId, int level = 0)

Parameters

listId RichTextListId

The existing document-local list identifier.

level int

The zero-based level to apply.

ToggleBold()

Toggles bold formatting across the selection.

public void ToggleBold()

ToggleItalic()

Toggles italic formatting across the selection.

public void ToggleItalic()

ToggleList(RichTextListDefinition, int)

Toggles an explicitly defined list at a nesting level.

public void ToggleList(RichTextListDefinition definition, int level = 0)

Parameters

definition RichTextListDefinition

The complete caller-defined list.

level int

The zero-based level to apply.

ToggleScript(RichTextScript)

Toggles a caller-selected superscript or subscript state.

public void ToggleScript(RichTextScript script)

Parameters

script RichTextScript

The script state to toggle.

ToggleStrikethrough(RichTextStrikethroughStyle)

Toggles a caller-selected strikethrough style.

public void ToggleStrikethrough(RichTextStrikethroughStyle style)

Parameters

style RichTextStrikethroughStyle

The style to apply when enabling strikethrough.

ToggleUnderline(RichTextUnderlineStyle)

Toggles a caller-selected underline style.

public void ToggleUnderline(RichTextUnderlineStyle style)

Parameters

style RichTextUnderlineStyle

The style to apply when enabling underline.

UpdateCharacterFormat(Func<RichTextCharacterFormat, RichTextCharacterFormat>)

Updates character formatting across the selection.

public void UpdateCharacterFormat(Func<RichTextCharacterFormat, RichTextCharacterFormat> update)

Parameters

update Func<RichTextCharacterFormat, RichTextCharacterFormat>

The transformation applied to each selected run.

UpdateParagraphFormat(Func<RichTextParagraphFormat, RichTextParagraphFormat>)

Updates paragraph formatting across every intersecting paragraph.

public void UpdateParagraphFormat(Func<RichTextParagraphFormat, RichTextParagraphFormat> update)

Parameters

update Func<RichTextParagraphFormat, RichTextParagraphFormat>

The transformation applied to each paragraph format.

Events

PropertyChanged

public event PropertyChangedEventHandler? PropertyChanged

Event Type

PropertyChangedEventHandler