Issue of comboBox in WPF window displayed using Show (not ShowDialog) in VSTO project

Copper Contributor

In a VSTO solution (Excel workbook document-level), when a Window containing a ComboBox is displayed using Show() instead of ShowDialog() the popup list will close as soon as the mouse is released, contrary to expected behavior of remaining open until a selection is made or the control loses focus.

Moreover, if the ComboBox is clicked and released (causing the list to flash on and off) without a selection being made, the window itself (the top bar and minimize/maximize/close buttons) is not clickable.
Other controls in the window body continue to function.

It’s a little better with office 2013 but not acceptable : The combobox items are properly displayed but once the mouse goes on any item that’s not actually selected, the list disappear.

Someone tested for me with office 365 and it’s working for him…

The only way to use combobox is to not release the mouse click for selecting a new item.

We have a plugins system that allows developers (these can be space engineers that do small code to get technical enhancements to the software like power or thermal calculations) to extend functions of the main application and they may create WPF windows as well as display them using Show (and not ShowDialog) so we can’t use custom hack as it would mean that we ask every third parties developers to do so and it’s not acceptable.

The only way to ensure comboboxes work as expected is to create every window in a separated thread, but everything must be thread safe (UI’s actions) and so still not acceptable also for same reason than previously mentioned .

I could ask my customer to forget about the 2010 compatibility but the problem is still present in Office 2013, so it will really be difficult for him to ear that.

Steps to reproduce :
1 - Ensure Excel 2010 is installed.
2 - Create a new Excel workbook (VSTO) project on visual studio.
3 - To allow adding new WPF window from Visual Studio, open the csproj with a text editor and change ProjectTypeGuids tag to include : {60dc8134-eba5-43b8-bcc9-bb4bc16c2548}.
4 - Add System.Xaml in references of the project. Clean the solution, close it and reopen it.
5 - Create a new WPF window and add to it a combobox with items in it.
6 - In the ThisWorkbook_Startup event of the ThisWorkbook.cs file, create an instance of the window and launch the “window.Show()” function.
7 - Start the project (Ensure it launches with Excel 2010).
8 - When window is shown, click on the combobox (don’t let the mouse button pressed) : the list is not displayed, window is locked and can’t be closed / minimized…

Repeat these steps with Excel 2013 : The list is displayed. Move the cursor to an item : The list disappears and same behaviour than before.


I attached a sample project made with VS 2015.


Thank you very much for providing us a solution.

Best regards,

Guillaume

1 Reply