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
Anchor
Gets the fixed endpoint.
public int Anchor { get; }
Property Value
CharacterFormat
Gets the live bindable character-format facade.
public RichTextSelectionCharacterFormat CharacterFormat { get; }
Property Value
ParagraphFormat
Gets the live bindable paragraph-format facade.
public RichTextSelectionParagraphFormat ParagraphFormat { get; }
Property Value
Range
Gets the current UTF-16 document range.
public TextSpan Range { get; }
Property Value
State
Gets the anchor and active endpoints.
public TextSelectionState State { get; }
Property Value
Text
Gets the selected logical plain text.
public string Text { get; }
Property Value
TypingCharacterFormat
Gets the declared character format used by newly typed text.
public RichTextCharacterFormat TypingCharacterFormat { get; }
Property Value
TypingParagraphFormat
Gets the paragraph format used by newly typed text.
public RichTextParagraphFormat TypingParagraphFormat { get; }
Property Value
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
deltaintThe 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
editAction<RichTextDocumentEdit>The content edits.
selectionAfterTextSelectionStateThe selection in the resulting document.
optionsRichTextEditOptionsHistory and application metadata.
InsertField(string, string)
Replaces selected content with a field result.
public void InsertField(string instruction, string result)
Parameters
InsertImage(RichTextImage)
Replaces selected content with one inline image.
public void InsertImage(RichTextImage image)
Parameters
imageRichTextImageThe owned image value.
RemoveLinks()
Removes hyperlinks intersecting the selection.
public void RemoveLinks()
ReplaceFragment(RichTextDocumentFragment)
Replaces selected content with a portable rich fragment.
public void ReplaceFragment(RichTextDocumentFragment fragment)
Parameters
fragmentRichTextDocumentFragmentThe fragment to insert.
ReplaceText(string?)
Replaces selected content and collapses the caret after the insertion.
public void ReplaceText(string? text)
Parameters
textstringThe replacement text. Null is treated as empty.
RestartList(int)
Restarts selected numbered-list items at a positive value.
public void RestartList(int startAt)
Parameters
startAtintThe new positive counter value.
Select(TextSelectionState)
Sets a directional selection, clamped to the document.
public void Select(TextSelectionState selection)
Parameters
selectionTextSelectionStateThe new selection.
Select(TextSpan)
Moves the selection to a validated document range.
public void Select(TextSpan range)
Parameters
rangeTextSpanThe new range.
SetLink(string, string?)
Creates or replaces a hyperlink over the selection.
public void SetLink(string target, string? toolTip = null)
Parameters
SetList(RichTextListDefinition, int)
Creates and applies an explicitly defined list.
public void SetList(RichTextListDefinition definition, int level = 0)
Parameters
definitionRichTextListDefinitionThe complete caller-defined list.
levelintThe 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
listIdRichTextListIdThe existing document-local list identifier.
levelintThe 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
definitionRichTextListDefinitionThe complete caller-defined list.
levelintThe zero-based level to apply.
ToggleScript(RichTextScript)
Toggles a caller-selected superscript or subscript state.
public void ToggleScript(RichTextScript script)
Parameters
scriptRichTextScriptThe script state to toggle.
ToggleStrikethrough(RichTextStrikethroughStyle)
Toggles a caller-selected strikethrough style.
public void ToggleStrikethrough(RichTextStrikethroughStyle style)
Parameters
styleRichTextStrikethroughStyleThe style to apply when enabling strikethrough.
ToggleUnderline(RichTextUnderlineStyle)
Toggles a caller-selected underline style.
public void ToggleUnderline(RichTextUnderlineStyle style)
Parameters
styleRichTextUnderlineStyleThe style to apply when enabling underline.
UpdateCharacterFormat(Func<RichTextCharacterFormat, RichTextCharacterFormat>)
Updates character formatting across the selection.
public void UpdateCharacterFormat(Func<RichTextCharacterFormat, RichTextCharacterFormat> update)
Parameters
updateFunc<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
updateFunc<RichTextParagraphFormat, RichTextParagraphFormat>The transformation applied to each paragraph format.
Events
PropertyChanged
public event PropertyChangedEventHandler? PropertyChanged