ContextMenu on WindowsFormsHost control

2020-03-04 02:52发布

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?

1条回答
该账号已被封号
2楼-- · 2020-03-04 03:14

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.

查看更多
登录 后发表回答