HOW TO CREATE A RIGHT-CLICK CONTEXT MENU FOR A BUTTON IN WPF?

Madam Walker

Total Post:22

Points:154
Posted by  Madam Walker
WPF 
WPF
 1864  View(s)
Ratings:
Rate this:

How to create a right-click context menu for a button in WPF?

i know how to create a left-click context menu for a button, but I am not too sure how to do it for a right click? (i.e. how to specify that the context menu should appear on a right-click, not a left click).

Thanks in advanced!

  1. Pravesh Singh

    Post:412

    Points:2888
    Re: How to create a right-click context menu for a button in WPF?

    here is a sample..

    <Button Content="button" Name="btn" Width="100">

                <Button.ContextMenu>

                    <ContextMenu>

                        <MenuItem Header="Cut"/>

                        <MenuItem Header="Copy"/>

                        <MenuItem Header="Paste"/>

                    </ContextMenu>

                </Button.ContextMenu>

            </Button>

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!