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

前端 未结 1 693
隐瞒了意图╮
隐瞒了意图╮ 2020-12-16 19:00

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 o

相关标签:
1条回答
  • 2020-12-16 19:10

    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

    0 讨论(0)
提交回复
热议问题