Strange case of the displaced Combo Box dropdown

I was adding a User Login window for a WPF application in a project that uses Caliburn.Micro. This Window was opened during the Caliburn.Micro OnViewLoaded event and included a ComboBox for user name selection.

Everything worked as expected (though the User Login window appeared before the main view was displayed). However, when the ComboBox was clicked to display the dropdown list of user names the list appeared in the upper left of the screen.

A search showed that this was a known problem and much discussed with some solutions and suggestions. None that I found were specific to working with Caliburn.Micro but this reply on StackOverflow by Ken Salter was enough to provide a succint solution to the problem: http://stackoverflow.com/questions/1998024/wpf-combobox-dropdown-part-appears-in-the-wrong-place

I adapted the code to work in the OnViewLoaded event and this fixed the problem. The ComboBox worked as expected, plus the User Login window appeared after the Main View was displayed.

The code:

              private Dispatcher _dispatcher = Dispatcher.CurrentDispatcher;
        private delegate void DelegateOpenWindow();
        private DelegateOpenWindow _delegateOpenUsersWindow;
 
        protected override void OnViewLoaded(object view)
        {
            base.OnViewLoaded(view);
            _delegateOpenUsersWindow = (ShowUserSelectWindow);
            _dispatcher.BeginInvoke(_delegateOpenUsersWindow);
        }
 
        private void ShowUserSelectWindow()
        {
            dynamic usersWindow = new ExpandoObject();
            usersWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            usersWindow.WindowStyle = WindowStyle.SingleBorderWindow;
            WindowManager.ShowDialog(new UsersViewModel(Events, WindowManager), null, usersWindow);
        }

Dispatcher is provided by the System.Windows.Threading library:

using System.Windows.Threading;

ShowUserSelectWindow is the method I have used to show the User LogIn window (named UsersViewModel). The Delegate and Dispatcher items are directly adapated from Ken Salters example.

Interestingly, one of the discussions included a comment from a Microsoft person where they said this bug would be fixed in .NET 4.5. My project is targetted at .NET 4.5, in VS2013 – Caliburn.Micro is version 1.5.2.0.

No doubt the code could be simplified further and perhaps Async / Await could be used – though I haven’t experimented with that yet.

Some further links on this subject:

http://stackoverflow.com/questions/4677701/c-sharp-strange-wpf-combobox-behavior

http://social.msdn.microsoft.com/forums/wpapps/en-us/545461b5-cf62-48e2-bcfb-2e872ecea639/wpf-tooltips-and-comboboxes-are-in-top-left-corner (the last post is the one that claims it is fixed in .NET 4.5).

https://www.devexpress.com/Support/Center/Question/Details/B202426