Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wpf extend contextmenu of textbox

I am searching for a way to extend the contextmenu of a textbox. I know there are dozens of solutions out there that recreate the contextmenu as a whole, but how on earth can I simply add one custom entry to a existing context menu?

Thanks Klaus

like image 285
klawusel Avatar asked Apr 28 '16 14:04

klawusel


1 Answers

 <TextBox>
        <TextBox.ContextMenu>
            <ContextMenu>
                <MenuItem Command="ApplicationCommands.Cut" />
                <MenuItem Command="ApplicationCommands.Copy" />
                <MenuItem Command="ApplicationCommands.Paste" />
                <MenuItem Command="ApplicationCommands.SelectAll" />
           //Your own item here
            </ContextMenu>
        </TextBox.ContextMenu>
    </TextBox>

Please not that all command are automatically operation and will work as expected

like image 124
suulisin Avatar answered Sep 27 '22 22:09

suulisin