klawusel
klawusel

Reputation: 691

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

Upvotes: 5

Views: 1775

Answers (1)

suulisin
suulisin

Reputation: 1434

 <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

Upvotes: 7

Related Questions