从 Excel 调用的 WPF 窗口,上下文菜单立即显示和消失 [英] WPF window invoked from Excel, Context menu shows and disappears immediately

查看:28
本文介绍了从 Excel 调用的 WPF 窗口,上下文菜单立即显示和消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 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:

https://connect.microsoft.com/VisualStudio/feedback/details/432998/excel-2007-vsto-custom-task-pane-with-wpf-context-menu-has-focus-问题

推荐的解决方法之一对我有用:

One of the recommended workarounds worked for me:

http://blogs.msdn.com/b/vsod/archive/2009/12/16/excel-2007-wpf-events-are-not-fired-for-items-that-overlap-excel-ui-for-wpf-context-menus.aspx

这篇关于从 Excel 调用的 WPF 窗口,上下文菜单立即显示和消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆