Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add 'Select All' context menu item to default TextBox menu items

I have a TextBox in CellEdititngTemplate for DataGridTemplateColumn in my DataGrid and I want to show 4 context menu items (Cut, Copy, Paste, Select All) when my DatagridCell is in edit mode and user right-clicks on it.

I see that default right-click context menu for TextBox control contains only 3 menu items: Cut (Ctrl+X), Copy (Ctrl+C), Paste (Ctrl+V).

There's no 'Select All' context menu item though Ctrl+A works for TextBox. So the question is - how to add a new Context Menu item 'Select All' into TextBox context menu without loosing cut, copy, paste menu items and their functionality?

like image 522
AndreyS Avatar asked Apr 17 '15 08:04

AndreyS


1 Answers

I don't think you can change existing context menu, but you can create yours and repeat other commands

<ContextMenu>
     <MenuItem Command="ApplicationCommands.Cut" />
     <MenuItem Command="ApplicationCommands.Copy" />
     <MenuItem Command="ApplicationCommands.Paste" />
     <MenuItem Command="ApplicationCommands.SelectAll" />
</ContextMenu>
like image 85
Arsen Mkrtchyan Avatar answered Oct 03 '22 18:10

Arsen Mkrtchyan