Back to Devexpress

RichEditControl.AssignShortcutKeyToCommand(Keys, Keys, RichEditCommandId, RichEditViewType) Method

wpf-devexpress-dot-xpf-dot-richedit-dot-richeditcontrol-dot-assignshortcutkeytocommand-x28-keys-keys-richeditcommandid-richeditviewtype-x29.md

latest3.5 KB
Original Source

RichEditControl.AssignShortcutKeyToCommand(Keys, Keys, RichEditCommandId, RichEditViewType) Method

Assigns a shortcut key to a command. The shortcut key is available for the specified RichEditView.

Namespace : DevExpress.Xpf.RichEdit

Assembly : DevExpress.Xpf.RichEdit.v25.2.dll

NuGet Package : DevExpress.Wpf.RichEdit

Declaration

csharp
public void AssignShortcutKeyToCommand(
    Keys key,
    Keys modifier,
    RichEditCommandId commandId,
    RichEditViewType viewType
)
vb
Public Sub AssignShortcutKeyToCommand(
    key As Keys,
    modifier As Keys,
    commandId As RichEditCommandId,
    viewType As RichEditViewType
)

Parameters

NameTypeDescription
keyKeys

A Keys enumeration member specifying a key to assign.

| | modifier | Keys |

A Keys enumeration member specifying a modifier key.

| | commandId | RichEditCommandId |

A RichEditCommandId enumeration member specifying a command.

| | viewType | RichEditViewType |

A RichEditView specifying the view in which a shortcut will be effective

|

Remarks

Note that the RichEditControl’s shortcuts should be assigned after the control is initialized (e.g. in Window.Loaded event handler).

The code sample below assigns the Alt+Y shortcut to the CreateFieldCommand, allowing you to insert a field:

csharp
private void ThemedWindow_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
  richEditControl1.AssignShortcutKeyToCommand(Keys.Y, Keys.Alt, RichEditCommandId.CreateField, RichEditViewType.PrintLayout);
}
vb
Private Sub ThemedWindow_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs)
   richEditControl1.AssignShortcutKeyToCommand(Keys.Y, Keys.Alt, RichEditCommandId.CreateField, RichEditViewType.PrintLayout)
End Sub

To remove a command shortcut, use the RichEditControl.RemoveShortcutKey method.

See Also

RemoveShortcutKey

RichEditControl Class

RichEditControl Members

DevExpress.Xpf.RichEdit Namespace