10

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).

Many thanks.

Bek Raupov
  • 3,782
  • 3
  • 24
  • 42
RKM
  • 3,151
  • 9
  • 37
  • 50
  • 1
    are you sure you don't have the question reversed? contextmenu is triggered by a right-click by default, to trigger on a left-click is what takes extra work (don't know why you'd want that on a button though?) – sellmeadog Jul 21 '11 at 20:15

1 Answers1

27

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>

enter image description here

Undo
  • 25,519
  • 37
  • 106
  • 129
Bathineni
  • 3,436
  • 18
  • 25