WindowsFormsHost控件上的ContextMenu [英] ContextMenu on WindowsFormsHost control
问题描述
因此,我在WPF应用程序(承载Dundas图表)中有一个WindowsFormsHost控件,我想在其上放置一个ContextMenu.
So, I have a WindowsFormsHost control in my WPF app (hosting a Dundas Chart) and I want to put a ContextMenu on it.
我可以成功地将ContextMenu附加到任何常规WPF控件上,但不适用于WindowsFormsHost.我怀疑这是因为它在某种程度上是特殊的",并且适当的鼠标消息未到达所需的目的地.
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.
我该怎么做?
推荐答案
回答我自己的问题-通过在我托管的Windows控件(Dundas Chart控件)上捕获MouseDown事件,我完成了这项工作新事件.
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;
效果很好.
这篇关于WindowsFormsHost控件上的ContextMenu的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!