WPF window invoked from Excel, Context menu shows

2019-05-29 21:20发布

问题:

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.

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 ?

  • Shankar

回答1:

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-problems

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