Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1590
Add handler for XamContextMenu.ContextMenuOpeningEvent
posted

Hi,

I'm trying to create a single static method that will react to any ContextMenuOpeningEvent, raised by any XamContextMenu. I tried to subscribe like this:

EventManager.RegisterClassHandler(typeof(XamContextMenu), XamContextMenu.ContextMenuOpeningEvent, new RoutedEventHandler(OnContextMenuOpening), true); 

But for some reason the code never reaches my OnContextMenuOpening method. When I try to do the same for e.g. Button.ClickEvent this line works. How can I do this?

Regards, Stefan