I have a WPF configuration utility with a single window that runs during my WIX installer and can also be run independently after installation. SO contains solutions to bring the window to the front but they make it either always on top or the code returns immediately.
When the application starts, I want to bring the window to the front. Left to itself, it pops under my MSI dialog. I also want to let the user move other windows on top of it (it shouldn't be always on top), and I want to wait for the window to close in code. Perhaps I am being too picky as WPF does not appear to support this.
Currently, I have this:
MainWindow.Topmost = true;
MainWindow.Show();
MainWindow.Activate();
MainWindow.Topmost = false;
MainWindow.Focus();
It's great except that MainWindow.Show()
returns immediately and execution resumes. In the past, we were using
MainWindow.TopMost = true;
MainWindow.ShowDialog();
But then this window is always on top and obstructs all other windows (not the best user experience). Are there any other options? Please feel free to suggest I am architecting this incorrectly as well. Thank you!