从 Excel 调用的 WPF 窗口,上下文菜单立即显示和消失 [英] WPF window invoked from Excel, Context menu shows and disappears immediately
问题描述
我有一个 WPF 窗口,它有一个包含用户控件列表的 ItemsControl.每个用户控件都有一个按钮和一个列表框.在按钮上,我有一个上下文菜单,其中列出了一些选项.
I have a WPF window which has a ItemsControl which contains list of User controls. Each user control has a button and a list box. On the button i have a context menu which lists some option.
当我直接运行 WPF 窗口时,上下文菜单完美运行.现在我已经将 WPF 表单集成到了一个 excel 插件中.点击插件中的一个按钮,窗口就会显示出来.这工作正常
When i ran the WPF window directly the context menu works perfectly. Now i have integrated the WPF form in a excel add in. on click of a button in addin the window show up. This works fine
但是当从插件调用窗口并且我右键单击按钮以查看上下文菜单选项时,它出现并立即消失.
But when the window is called from addin and i right click the button to see the context menu options, it comes and immediately disappears.
知道我在这里遗漏了什么吗?
Any idea what i am missing here ?
- 香卡
推荐答案
我有一个使用 WPF 的 Excel 加载项显示您描述的行为.就我而言,这是此框架错误的连续错误:
I had an Excel-Add-In using WPF showing the behavior you describe. In my case it was a consecutive error of this framework bug:
推荐的解决方法之一对我有用:
One of the recommended workarounds worked for me:
这篇关于从 Excel 调用的 WPF 窗口,上下文菜单立即显示和消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!