New to Telerik UI for Xamarin? Download free 30-day trial

Commands

RadRichTextEditor provides the following commands of type ICommand:

  • UndoCommand
  • RedoCommand
  • CutCommand
  • CopyCommand
  • PasteCommand
  • ToggleBoldCommand
  • ToggleItalicCommand
  • ToggleUnderlineCommand
  • ToggleStrikethroughCommand
  • ToggleSubscriptCommand
  • ToggleSuperscriptCommand
  • ToggleBulletingCommand
  • ToggleNumberingCommand
  • SelectAllCommand
  • ClearFormattingCommand
  • AlignLeftCommand
  • AlignRightCommand
  • AlignCenterCommand
  • AlignJustifyCommand
  • IndentCommand
  • OutdentCommand
  • ApplyHyperlinkCommand
  • RemoveHyperlinkCommand
  • OpenHyperlinkCommand
  • InsertImageCommand
  • RemoveImageCommand

RadRichTextEditor Toolbar exposes some of the commands built-in. For more information please check the RadRichTextEditor Toolbar article.

Example

Through the provided commands you can execute the corresponding actions over RichTextEditor (for example apply bold text formatting) from a custom UI other than the RichTextEditor toolbar.

Following is an example how the RadRichTextEditor commands could be called on a button click action.

Let's add the RichTextEditor definition together with a few sample buttons wired to the editor's commands:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition />
    </Grid.RowDefinitions>
    <telerikCommon:RadUniformGrid>
        <Button Text="Bold"
                Command="{Binding Source={x:Reference richTextEditor}, Path=ToggleBoldCommand}" />
        <Button Text="Italic"
                Command="{Binding Source={x:Reference richTextEditor}, Path=ToggleItalicCommand}" />
        <Button Text="Underline"
                Command="{Binding Source={x:Reference richTextEditor}, Path=ToggleUnderlineCommand}" />
        <Button Text="Bullet List"
                Command="{Binding Source={x:Reference richTextEditor}, Path=ToggleBulletingCommand}" />
        <Button Text="Numbered List"
                Command="{Binding Source={x:Reference richTextEditor}, Path=ToggleNumberingCommand}" />
    </telerikCommon:RadUniformGrid>
    <telerikRichTextEditor:RadRichTextEditor x:Name="richTextEditor" Grid.Row="1" />
</Grid>

Add the required namespaces:

xmlns:telerikCommon="clr-namespace:Telerik.XamarinForms.Common;assembly=Telerik.XamarinForms.Common"
xmlns:telerikRichTextEditor="clr-namespace:Telerik.XamarinForms.RichTextEditor;assembly=Telerik.XamarinForms.RichTextEditor"

Now text formatting and creating lists can be executed over the editor through the sample buttons:

A sample Commands example can be found in the RichTextEditor/Features folder of the SDK Samples Browser application.

See Also

In this article