title: Bring MainWindow to front, not always on top, and wait for it to close
body: <p>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.</p>
  
  <p>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.</p>
  
  <p>Currently, I have this:</p>
  
  <pre><code>MainWindow.Topmost = true;
  MainWindow.Show();
  MainWindow.Activate();
  MainWindow.Topmost = false;
  MainWindow.Focus();
  </code></pre>
  
  <p>It's great except that <code>MainWindow.Show()</code> returns immediately and execution resumes. In the past, we were using</p>
  
  <pre><code>MainWindow.TopMost = true;
  MainWindow.ShowDialog();
  </code></pre>
  
  <p>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!</p>