New to Telerik UI for .NET MAUIStart a free 30-day trial

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.

CommandsDescription
UndoCommandGets a command to undo the last changes in the editor.
RedoCommandGets a command to redo the last changes in the editor.
ToggleBoldCommandGets a command to toggle the bold text in the editor.
ToggleItalicCommandGets a command to toggle the italic text in the editor.
ToggleUnderlineCommandGets a command to toggle the underline text in the editor.
ToggleStrikethroughCommandGets a command to toggle the strike-through text in the editor.
ToggleSubscriptCommandGets a command to toggle the subscript text in the editor.
ToggleSuperscriptCommandGets a command to toggle the superscript text in the editor.
ToggleBulletingCommandGets a command to toggle the bullets paragraph in the editor.
ToggleNumberingCommandGets a command to toggle the bullets paragraph in the editor.
ClearFormattingCommandGets a command to clear the formatting of the text in the editor.
AlignLeftCommandGets a command to apply left text alignment in the editor.
AlignRightCommandGets a command to apply right text alignment in the editor.
AlignCenterCommandGets a command to apply center text alignment in the editor.
AlignJustifyCommandGets a command to apply justify text alignment in the editor.
IndentCommandGets a command to indent the text in the editor.
OutdentCommandGets a command to outdent the text in the editor.
ApplyHyperlinkCommandGets a command to apply a hyperlink in the editor.
RemoveHyperlinkCommandGets a command to remove a hyperlink in the editor.
OpenHyperlinkCommandGets a command to open a hyperlink in the editor.
InsertImageCommandGets a command to insert an image in the editor. The command takes a single paramerer of type Telerik.Maui.Controls.RichTextEditor.RichTextImage.
RemoveImageCommandGets a command to remove an image in the editor.
SelectAllCommandGets a command to select all html in the editor.

The RadRichTextEditor Toolbar exposes some of the built-in commands. For more information, check the RadRichTextEditor 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:

xaml
<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:

XAML
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.

See Also