开发者

How to cancel a Context Menu Opened Event?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜