Visual Studio and .NET Framework Home
Excel 2007 VSTO Custom Task Pane with WPF Context Menu has focus problems
4/16/2009 11:27:43 AM
User(s) can reproduce this bug
When a WPF control with a context menu is hosted in a VSTO Custom Task Pane inside of Excel 2007 the context menu has focus problems. If the context menu extends past the bounds of the Custom Task Pane and the user clicks on it, the context menu does not receive the click and focus is shifted to whatever is behind the context menu item.
Additionally, the context menu will not open again once this happens, unless the user registers a right-click in Excel.
.NET Framework 3.5 SP1
Operating System Language
Steps to Reproduce
Create an Excel 2007 AddIn project.
Create a WPF user control with a nested context menu (2 levels should do it) and a Click handler on the leaf node menu item.
Use a Forms user control to host the WPF control, and add this to a new CustomTaskPane (just create one in the Startup method of the addin.)
Set a breakpoint in the Click handler for the menu item in the WPF user control.
Run the addin. Right-click on the control with the context menu. Navigate to the leaf node menu item, and left-click on the menu item, ensuring that the pointer is outside the bounds of the CustomTaskPane.
The breakpoint is not hit. The context menu closes. Focus is shifted to whatever was behind the menu item.
Now when you attempt to right-click to open the context menu again, the context menu opens briefly and then closes by itself.
The menu item should receive the mouse click and the breakpoint should be hit.
The WPF user control should retain focus.
The context menu should continue to function normally.
TAP Code (if applicable)
You can indicate your satisfaction with how Microsoft handled this issue by completing this quick
3 question survey
to post a comment.
Please enter a comment.
on 5/30/2011 at 12:21 AM
This issue also exists for Outlook if you use a WPF combobox with a long set of list items. If the combobox items go past the border of the application window, you lose focus to the application behind the active window when clicking a combobox selection.
Unsure at this point if you can alter the wpf style to get around this.
on 3/24/2010 at 10:41 AM
This is not just Excel 2007 or WPF, this is affecting me with Word 2007 and Windows Forms controls inside a custom task pane.
On my Custom Task Pane I have a Windows Forms ComboBox control and when 'dropped down' if I select an item that is showing outside the custom task pane, either on the document or outside the entire application itself, my selection is ignored.
on 10/26/2009 at 11:39 AM
I'm experiencing this as well. Unfortunately it also occurs with any WPF component that extends beyond the boundaries of the window in any Office application -- an example of this being the pop-up window of a ComboBox.
on 7/7/2009 at 12:02 PM
Thank you for reporting this issue. Though this issue is under investigation, we will likely not have a fix available in .NET 4.0. We will update this bug again when we are able to fix the issue in a future release. Thanks!
on 4/19/2009 at 11:38 PM
Thanks for reporting this issue. We are escalating this bug to the product unit who works on that specific feature area. The team will review this issue and make a decision on whether they will fix it or not for the next release.
Visual Studio Product Team
to post a workaround.
Please enter a workaround.
on 10/11/2011 at 4:13 AM
Please consider using this workaround. It perfectly works for Office 2007/2010.
on 7/21/2010 at 8:28 AM
You can also handle the keyboard event; this will fire correctly even if the box displays outside the bounds of the pane.
on 10/26/2009 at 11:42 AM
Controls that extend beyond the boundary of the Office window can either be modified so that they attempt to position themselves within the window boundaries, or they can be hosted in a Popup (http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.popup(VS.85).aspx).
© 2014 Microsoft