I want to cancel the Context Menu Opened Event of a TreeViewItem
private void ContextMenu_Opened(object sender, RoutedEventArgs e)
{
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
The contextmenu event fires when the user attempts to open a context menu. This event is typically triggered by clicking the right mouse button, or by pressing the context menu key.
When we click the right mouse button on our desktop, a menu-like box appears and this box is called the context menu. In JavaScript, a context menu event runs when a user tries to open a context menu. This can be done by clicking the right mouse button.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With