Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Custom Options to WPF RichTextBox Context Menu

I have a WPF RichTextBox and I want to add some more options to the default context menu. I dont want to loose the default menu options (Cut, Copy, Paste). Can you help me out?

Thanks

like image 803
Vasanth91 Avatar asked Sep 07 '25 11:09

Vasanth91


1 Answers

Extending the previous answer:

<RichTextBox x:Name="rtbTest">
   <RichTextBox.ContextMenu>
     <ContextMenu>
       <MenuItem Command="ApplicationCommands.Cut"/>
       <MenuItem Command="ApplicationCommands.Copy"/>
       <MenuItem Command="ApplicationCommands.Paste"/>
       <MenuItem Header="Custom Item"/>
    </ContextMenu>
  </RichTextBox.ContextMenu>
</RichTextBox>

Each command is provided with a default UI Text and Key Gesture, by omitting them (in this case the 'Header') from your definition they will fallback to the default, which will be in the users own preferred language.

like image 120
user3073886 Avatar answered Sep 10 '25 21:09

user3073886