Commands in WPF RichTextBox (SfRichTextBoxAdv)
4 Sep 2020 / 9 minutes to read
Commands are a way to handle user interface (UI) actions. They are a loosely coupled way to bind the UI to the logic that performs the action. The SfRichTextBoxAdv supports commands for mostly used operations which are classified below.
-
Character Formatting – Bold, Italic, Underline, Strike through, Baseline alignment, Font family, Font size, Font color and Highlight color.
-
Paragraph Formatting – Left indent, Right indent, First line indent, Text alignment, Before spacing, After spacing, Line spacing, Line spacing type, Increase indent, Decrease indent and Change list type.
-
Clipboard – Cut, Copy and Paste.
-
History – Undo and Redo.
-
Import and Export – Open document, Save document and New document.
-
Comments – New comment, Delete comment, Delete all comments, Previous comment, Next comment and Show comments.
-
Table – Insert table, Insert row, Insert column, Delete table, Delete row, Delete column and Merge selected cells, Select cell, Select column, Select row, Select table and Align cell content.
-
UI options – Show hyperlink dialog, Show options pane and Layout type.
-
Insert – Insert picture and Insert hyperlink.
-
Document Styles – Create, modify, apply and clear style.
UI Command to access character formatting
The following code example demonstrates how to bind commands for applying character format.
<!-- Binds button to the BoldCommand -->
<Button Content="Bold" Command="RichTextBoxAdv:SfRichTextBoxAdv.BoldCommand" CommandTarget="{Binding ElementName=richTextBoxAdv}"/>
<!-- Binds button to the ItalicCommand -->
<Button Content="Italic" Command="RichTextBoxAdv:SfRichTextBoxAdv.ItalicCommand" CommandTarget="{Binding ElementName=richTextBoxAdv}"/>
The following code example demonstrates how to bind commands with parameter.
<Button Content="Textalignment" Command="Syncfusion:SfRichTextBoxAdv.TextAlignmentCommand" CommandTarget="{Binding ElementName=richTextBoxAdv}" CommandParameter="Right" />
List of available Commands
The following table contains the list of available UI Commands in SfRichTextBoxAdv.
Command Name |
Description |
Command parameter (optional) |
---|---|---|
AddToDictionaryCommand |
Represents the command to add the selected or specified custom word into the custom dictionary. |
The custom word to be added. |
AfterSpacingCommand |
Represents the command to apply after spacing for the selected paragraphs. |
The after spacing value to be applied. |
AutoFitTableCommand |
Represents the command that fits the columns width of selected table based on the specified `AutoFitType`. |
The `AutoFitType` to fit the columns of the table. |
BackSpaceKeyCommand |
Represents the command that performs action for "Backspace" key. |
NA |
BaselineAlignmentCommand |
Represents the command to apply `BaselineAlignment` for the selected text. |
The baseline alignment value to be applied. |
BeforeSpacingCommand |
Represents the command to apply before spacing for the selected paragraphs. |
The before spacing value to be applied. |
BoldCommand |
Represents the command to toggle bold style for the selected text. |
NA |
CellBottomMarginCommand |
Represents the command to apply bottom margin for the selected table cells. |
The bottom margin value to be applied. |
CellContentAlignmentCommand |
Represents the command to apply content alignment for the selected table cells. |
The cell content alignment value to be applied. |
CellLeftMarginCommand |
Represents the command to apply left margin for the selected table cells. |
The left margin value to be applied. |
CellRightMarginCommand |
Represents the command to apply right margin for the selected table cells. |
The right margin value to be applied. |
CellSpacingCommand |
Represents the command to apply cell spacing for the selected table. |
The cell spacing value to be applied. |
CellTopMarginCommand |
Represents the command to apply top margin for the selected table cells. |
The top margin value to be applied. |
CellVerticalAlignmentCommand |
Represents the command to apply vertical alignment for the selected table cells. |
The vertical alignment value to be applied. |
ChangeAllSpellingCommand |
Represents the command that changes all occurrences of a selected misspelled word. |
The word to be replaced. |
ChangeSpellingCommand |
Represents the command that changes the selected misspelled word. |
The word to be replaced. |
CheckSpellingCommand |
Represents the command that checks spelling mistakes in the document of `SfRichTextBoxAdv` control. |
NA |
ControlDownKeyCommand |
Represents the command that performs navigation for "CTRL + DOWN" key. |
NA |
ControlEndKeyCommand |
Represents the command that performs navigation for "CTRL + END" key. |
NA |
ControlHomeKeyCommand |
Represents the command that performs navigation for "CTRL + HOME" key. |
NA |
ControlLeftKeyCommand |
Represents the command that performs navigation for "CTRL + LEFT" key. |
NA |
ControlRightKeyCommand |
Represents the command that performs navigation for "CTRL + RIGHT" key . |
NA |
ControlShiftDownKeyCommand |
Represents the command that performs selection for "CTRL + SHIFT + DOWN" key. |
NA |
ControlShiftEndKeyCommand |
Represents the command that performs selection for "CTRL + SHIFT + END" key. |
NA |
ControlShiftHomeKeyCommand |
Represents the command that performs selection for "CTRL + SHIFT + HOME" key. |
NA |
ControlShiftLeftKeyCommand |
Represents the command that performs selection for "CTRL + SHIFT + LEFT" key. |
NA |
ControlShiftRightKeyCommand |
Represents the command that performs selection for "CTRL + SHIFT + RIGHT" key. |
NA |
ControlShiftUpKeyCommand |
Represents the command that performs selection for "CTRL + SHIFT + UP" key. |
NA |
ControlUpKeyCommand |
Represents the command that performs navigation for "CTRL + UP" key. |
NA |
CopyCommand |
Represents the command that copies the selected contents to clipboard. |
NA |
CopyHyperlinkCommand |
Represents the command that copies the selected hyperlink to clipboard. |
NA |
CutCommand |
Represents the command that removes the selected contents from `SfRichTextBoxAdv` control and copies the same to clipboard. |
NA |
DecreaseFontSizeCommand |
Represents the command to decrease font size for the selected text. |
The font size value to be applied. |
DecreaseIndentCommand |
Represents the command to decrease left indent for the selected paragraphs. |
NA |
DefaultCellBottomMarginCommand |
Represents the command to apply bottom margin for the selected table. |
The cell bottom margin value to be applied. |
DefaultCellLeftMarginCommand |
Represents the command to apply left margin for the selected table. |
The cell left margin value to be applied. |
DefaultCellRightMarginCommand |
Represents the command to apply right margin for the selected table. |
The cell right margin value to be applied. |
DefaultCellTopMarginCommand |
Represents the command to apply top margin for the selected table. |
The cell top margin value to be applied. |
DeleteAllCommentsCommand |
Represents the command to delete all the comments in the document. |
NA |
DeleteColumnCommand |
Represents the command to delete the selected column of a table. |
NA |
DeleteCommentCommand |
Represents the command that deletes the selected comment. |
NA |
DeleteKeyCommand |
Represents the command that performs action for "DELETE" key. |
NA |
DeleteRowCommand |
Represents the command to delete the selected row of a table. |
NA |
DeleteTableCommand |
Represents the command to delete the selected table. |
NA |
DownKeyCommand |
Represents the command that performs navigation for "DOWN" key. |
NA |
EndKeyCommand |
Represents the command that performs navigation for "END" key. |
NA |
EnterKeyCommand |
Represents the command that performs action for "ENTER" key. |
NA |
FirstLineIndentCommand |
Represents the command to apply first line indent for the selected paragraphs. |
The first line indent value to be applied. |
FontColorCommand |
Represents the command to apply font color for the selected text. |
The font color value to be applied. |
FontFamilyCommand |
Represents the command to apply font family for the selected text. |
The font family value to be applied. |
FontSizeCommand |
Represents the command to apply font size for the selected text. |
The font size value to be applied. |
HighlightColorCommand |
Represents the command to apply `HighlightColor` for the selected text. |
The highlight color value to be applied. |
HomeKeyCommand |
Represents the command that performs navigation for "HOME" key. |
NA |
IgnoreAllSpellingErrorsCommand |
Represents the command that ignores all the occurrence of a selected misspelled word. |
The misspelled word to be ignored. |
IncreaseFontSizeCommand |
Represents the command to increase font size for the selected text. |
The font size value to be applied. |
IncreaseIndentCommand |
Represents the command to increase indent for the selected paragraphs. |
NA |
InsertBreakCommand |
Represents the command that inserts a break at selection. |
The break type to be inserted |
InsertColumnCommand |
Represents the command that inserts a column to the selected table. |
The `ColumnPlacement` value to insert column. |
InsertHyperlinkCommand |
Represents the command that inserts a hyperlink at selection. |
The hyperlink to be inserted. |
InsertPictureCommand |
Represents the command that inserts a picture at selection. |
The picture to be inserted. |
InsertRowCommand |
Represents the command that inserts a row to the selected table. |
The `RowPlacement` value to insert row. |
InsertTableCommand |
Represents the command that inserts a table at selection. |
The row and column count of the table. |
ItalicCommand |
Represents the command to toggle italic style for the selected text. |
NA |
LayoutTypeCommand |
Represents the command to change layout type of the `SfRichTextBoxAdv` control. |
The layout type to set for the `SfRichTextBoxAdv` control. |
LeftIndentCommand |
Represents the command to apply left indent for the selected paragraphs. |
The left indent value to be applied. |
LeftKeyCommand |
Represents the command that performs navigation for "LEFT" key. |
NA |
LineSpacingCommand |
Represents the command to apply line spacing for the selected paragraphs. |
The line spacing value to be applied. |
LineSpacingTypeCommand |
Represents the command to apply `LineSpacingType` for the selected paragraphs. |
The `LineSpacingType` value to be applied. |
MergeSelectedCellsCommand |
Represents the command that merges the selected table cells. |
NA |
NavigateHyperlinkCommand |
Represents the command that performs navigation for the selected hyperlink. |
NA |
NewCommentCommand |
Represents the command that adds a comment at the selection. |
NA |
NewDocumentCommand |
Represents the command that creates a new document in `SfRichTextBoxAdv` control. |
NA |
NextCommentCommand |
Represents the command that performs navigation to next comment in the document. |
NA |
OpenDocumentCommand |
Represents the command that opens an existing document in the `SfRichTextBoxAdv` control. |
NA |
PageDownKeyCommand |
Represents the command that performs navigation for "PAGEDOWN" key. |
NA |
PageFitCommand |
Represents the command to apply `PageFitType` for the `SfRichTextBoxAdv` control. |
The `PageFitType` value to be applied. |
PageUpKeyCommand |
Represents the command that performs navigation for "PAGEUP" key. |
NA |
PasteCommand |
Represents the command that pastes the content from clipboard to `SfRichTextBoxAdv` control. |
NA |
PreviousCommentCommand |
Represents the command that performs navigation to previous comment in the document. |
NA |
PrintDocumentCommand |
Represents the command that prints the document of `SfRichTextBoxAdv` control. |
NA |
RedoCommand |
Represents the command that redo the last undo operation in `SfRichTextBoxAdv` control. |
NA |
RemoveHyperlinkCommand |
Represents the command that removes the selected hyperlink. |
NA |
RightIndentCommand |
Represents the command to apply right indent for the selected paragraphs. |
The right indent value to be applied. |
RightKeyCommand |
Represents the command that performs navigation for "RIGHT" key. |
NA |
SaveAsDocumentCommand |
Represents the command that saves the document of `SfRichTextBoxAdv` control. |
NA |
SaveDocumentCommand |
Represents the command that saves the document of `SfRichTextBoxAdv` control. |
NA |
SelectAllCommand |
Represents the command that selects all the content of `SfRichTextBoxAdv` control. |
NA |
SelectCellCommand |
Represents the command that selects the table cell. |
NA |
SelectColumnCommand |
Represents the command that selects the entire column of a table. |
NA |
SelectRowCommand |
Represents the command that selects the entire row of a table. |
NA |
SelectTableCommand |
Represents the command that selects the table. |
NA |
ShiftDownKeyCommand |
Represents the command that performs selection for "SHIFT + DOWN" key. |
NA |
ShiftEndKeyCommand |
Represents the command that performs selection for "SHIFT + END" key. |
NA |
ShiftEnterKeyCommand |
Represents the command that performs action [inserts line break] for "SHIFT + ENTER" key. |
NA |
ShiftHomeKeyCommand |
Represents the command that performs selection for "SHIFT + HOME" key. |
NA |
ShiftLeftKeyCommand |
Represents the command that performs selection for "SHIFT + LEFT" key. |
NA |
ShiftRightKeyCommand |
Represents the command that performs selection for "SHIFT + RIGHT" key. |
NA |
ShiftTabKeyCommand |
Represents the command that performs selection for "SHIFT + TAB" key. |
NA |
ShiftUpKeyCommand |
Represents the command that performs selection for "SHIFT + UP" key. |
NA |
ShowBordersAndShadingDialogCommand |
Represents the command that shows the borders and shading dialog. |
NA |
ShowCellOptionsDialogCommand |
Represents the command that shows the cell options dialog. |
NA |
ShowCommentsCommand |
Represents the command to show or hide comments in the `SfRichTextBoxAdv` control. |
NA |
ShowEncryptDocumentDialogCommand |
Represents the command that shows dialog to specify password for opening encrypted Word document. |
NA |
ShowFindAndReplaceDialogCommand |
Represents the command that shows the find and replace dialog. |
The Boolean value to show find or replace tab. |
ShowFontDialogCommand |
Represents the command that shows the font dialog. |
NA |
ShowHyperlinkDialogCommand |
Represents the command that shows the hyperlink dialog. |
NA |
ShowInsertTableDialogCommand |
Represents the command that shows the insert table dialog. |
NA |
ShowListDialogCommand |
Represents the command that shows the list dialog. |
NA |
ShowOptionsPaneCommand |
Represents the command that shows the options pane. |
NA |
ShowParagraphDialogCommand |
Represents the command that shows the paragraph dialog. |
NA |
ShowSpellingPaneCommand |
Represents the command that shows the spelling pane. |
NA |
ShowTableDialogCommand |
Represents the command that shows the table dialog. |
NA |
ShowTableOptionsDialogCommand |
Represents the command that shows the table options dialog. |
NA |
SpaceKeyCommand |
Represents the command that performs action [inserts space] for "SPACE" key. |
NA |
StrikeThroughCommand |
Represents the command to apply `StrikeThrough` for the selected text. |
The strike through value to be applied. |
TabKeyCommand |
Represents the command that performs action [inserts tab] for "TAB" key. |
NA |
TableAlignmentCommand |
Represents the command to apply table alignment for the selected table. |
The table alignment value to be applied. |
TableLeftIndentCommand |
Represents the command to apply left indent for the selected table. |
The left indent value to be applied. |
TextAlignmentCommand |
Represents the command to apply text alignment for the selected paragraphs. |
The value to be applied. |
ToggleBaselineAlignmentCommand |
Represents the command that toggles baseline alignment for the selected text. |
The baseline alignment value to be applied. |
ToggleBeforeSpacingCommand |
Represents the command that toggles before spacing for the selected paragraphs. |
NA |
ToggleHighlightColorCommand |
Represents the command that toggles highlight color for the selected text. |
NA |
ToggleUnderlineCommand |
Represents the command that toggles underline for the selected text. |
The `Underline` value to be applied. |
UnderlineCommand |
Represents the command to apply underline for the selected text. |
The `Underline` value to be applied. |
UndoCommand |
Represents the command that undo the last edit operation in `SfRichTextBoxAdv` control. |
NA |
UpKeyCommand |
Represents the command that performs navigation for "UP" key. |
NA |
ShowStyleDialogCommand |
Represents the command that shows the create style dialog. |
NA |
ShowStylesDialogCommand |
Represents the command that shows the modify style dialog. |
NA |
ApplyStyleCommand |
Represents the command, which requests to apply style for the selected paragraph. |
Name of the Style |
ClearFormattingCommand |
Represents the command, which requests to remove formatting from the selected paragraph. |
NA |