Intersoft ClientUI Documentation
How-to: Attach a Context Menu to Rich Text Box

This example shows how to attach the context menu to the RichTextBox.

Example

Description

To attach the UXContextMenu to an element or control, you attach the ContextMenuService.ContextMenu or ContextMenuService.ContextMenuName property to the desired element, and specify the instance or name of the target context menu.

The following code example shows how to attach the context menu to your RichTextBox

Code

XAML
Copy Code
<RichTextBox Name="RichTextBox1" Margin="24" Padding="12"             Intersoft:ContextMenuService.ContextMenuName="FormattingContextMenu">    <Paragraph>        <Run Text="Type some text or select a word to see how RoutedUICommand and HybridRoutedCommand works. Notice that the toolbar buttons, menu items and context menu consistently responding to the selection. To learn more about ClientUI's Commanding Framework, click on the Info button in the toolbar above."/>    </Paragraph></RichTextBox><Intersoft:UXContextMenu x:Name="FormattingContextMenu">    <Intersoft:UXMenuItem Header="Cut" InputGestureText="Ctrl+Shift+X" IsEnabled="True" />    <Intersoft:UXMenuItem Header="Copy" InputGestureText="Ctrl+Shift+C" IsEnabled="True" />    <Intersoft:UXMenuItem Header="Paste" InputGestureText="Ctrl+Shift+V" IsEnabled="True" /></Intersoft:UXContextMenu>
See Also

Concepts

Other Resources