开发者

How to cancel a Context Menu Opened Event?

开发者 https://www.devze.com 2023-03-27 10:57 出处:网络
I want to cancel the Context Menu Opened Event of a TreeViewItem private void ContextMenu_Opened(object sender, RoutedEventArgs e)

I want to cancel the Context Menu Opened Event of a TreeViewItem

private void ContextMenu_Opened(object sender, RoutedEventArgs e)
    {
  开发者_如何学Python      e.Handled = true;
    }

i thought this should work but instead i got a tiny context menu that has no menu items but i would like to have nothing appearing. Thanks


You should use the ContextMenuOpening event of the control that owns the context menu, which is fired right before the context menu opens. There you can change the context menu or suppress it. Your code for the event to suppress works if you use the Opening event, see this article for further infos.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号