Commands
The .NET MAUI RichTextEditor provides the a long list of commands (of type ICommand
) that allow you to perform various operations on the text.
Commands | Description |
---|---|
UndoCommand | Gets a command to undo the last changes in the editor. |
RedoCommand | Gets a command to redo the last changes in the editor. |
ToggleBoldCommand | Gets a command to toggle the bold text in the editor. |
ToggleItalicCommand | Gets a command to toggle the italic text in the editor. |
ToggleUnderlineCommand | Gets a command to toggle the underline text in the editor. |
ToggleStrikethroughCommand | Gets a command to toggle the strike-through text in the editor. |
ToggleSubscriptCommand | Gets a command to toggle the subscript text in the editor. |
ToggleSuperscriptCommand | Gets a command to toggle the superscript text in the editor. |
ToggleBulletingCommand | Gets a command to toggle the bullets paragraph in the editor. |
ToggleNumberingCommand | Gets a command to toggle the bullets paragraph in the editor. |
ClearFormattingCommand | Gets a command to clear the formatting of the text in the editor. |
AlignLeftCommand | Gets a command to apply left text alignment in the editor. |
AlignRightCommand | Gets a command to apply right text alignment in the editor. |
AlignCenterCommand | Gets a command to apply center text alignment in the editor. |
AlignJustifyCommand | Gets a command to apply justify text alignment in the editor. |
IndentCommand | Gets a command to indent the text in the editor. |
OutdentCommand | Gets a command to outdent the text in the editor. |
ApplyHyperlinkCommand | Gets a command to apply a hyperlink in the editor. |
RemoveHyperlinkCommand | Gets a command to remove a hyperlink in the editor. |
OpenHyperlinkCommand | Gets a command to open a hyperlink in the editor. |
InsertImageCommand | Gets a command to insert an image in the editor. The command takes a single paramerer of type Telerik.Maui.Controls.RichTextEditor.RichTextImage . |
RemoveImageCommand | Gets a command to remove an image in the editor. |
SelectAllCommand | Gets a command to select all html in the editor. |
The
RadRichTextEditor
Toolbar exposes some of the built-in commands. For more information, check theRadRichTextEditor
Toolbar article.
Example: Executing Actions through Commands
You can execute the actions in the RichTextEditor through the provided commands. For example, you can apply bold text formatting from a custom UI other than the RichTextEditor toolbar.
The following example how to call the RadRichTextEditor
commands on a button click action.
1. Let's add the RichTextEditor definition together with a few sample buttons wired to the editor's commands:
<Grid RowDefinitions="Auto, *">
<telerik:RadUniformGrid>
<Button Text="Bold"
Command="{Binding ToggleBoldCommand, Source={x:Reference richTextEditor}}"
Margin="0, 0, 10, 10" />
<Button Text="Italic"
Command="{Binding ToggleItalicCommand, Source={x:Reference richTextEditor}}"
Margin="0, 0, 10, 10" />
<Button Text="Underline"
Command="{Binding ToggleUnderlineCommand, Source={x:Reference richTextEditor}}"
Margin="0, 0, 10, 10" />
<Button Text="Bulleted List"
Command="{Binding ToggleBulletingCommand, Source={x:Reference richTextEditor}}"
Margin="0, 0, 10, 10" />
<Button Text="Numbered List"
Command="{Binding ToggleNumberingCommand, Source={x:Reference richTextEditor}}"
Margin="0, 0, 10, 10" />
</telerik:RadUniformGrid>
<telerik:RadRichTextEditor x:Name="richTextEditor" Grid.Row="1" />
</Grid>
2. Add the required namespaces:
xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"
For a runnable example with the RichTextEditor commands, see the SDKBrowser Demo Application and go to RichTextEditor > Features.