ContextMenu on WindowsFormsHost control

南笙酒味 提交于 2019-12-30 06:57:09

问题


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:


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.



来源:https://stackoverflow.com/questions/341747/contextmenu-on-windowsformshost-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!