Show menu programmatically in WPF

后端 未结 4 1840
名媛妹妹
名媛妹妹 2020-12-17 09:57

How can I open menu (System.Windows.Controls.Menu) programmatically in WPF?

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-17 10:25

    Check out this example on how to open a context menu.

    http://www.uxpassion.com/2009/01/how-to-enable-and-show-context-menu-on-left-click-in-wpf/

    In summary

    You can just call:

    YourContextMenu.IsOpen = true;
    

    This will display the context menu, just make sure its associated with a FrameworkElement on which it is displaying)

提交回复
热议问题