Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ContextMenu on WindowsFormsHost control

So, I have a WindowsFormsHost control in my WPF app (hosting a Dundas Chart) and I want to put a ContextMenu on it.

I can successfully attach a ContextMenu to any normal WPF control, but it's not working for the WindowsFormsHost. I suspect this is becuase it's "special" in some way and the appropriate mouse messages aren't reaching the required destination.

How do I do this?

like image 917
Craig Shearer Avatar asked Dec 23 '22 13:12

Craig Shearer


1 Answers

Answering my own question - I have made this work by capturing the MouseDown event on my Windows control I'm hosting (the Dundas Chart control) and then firing a new event.

The event handler for the new event then does:

graph.ContextMenu.IsOpen = true;

Works nicely.

like image 198
Craig Shearer Avatar answered Jan 06 '23 22:01

Craig Shearer