title: How to make WPF pop-up windows not be hidden behind main application?
body: <p>In a WPF application, I have buttons which pop up instances of windows. </p>
  
  <ul>
  <li>I click the first button and the first window pops up correctly in <strong>front</strong> of the main application.</li>
  <li>I click the second button and the second window pops up correct in <strong>front</strong> of the main application. However, the <strong>first</strong> window now moves <strong>behind</strong> the main application. This is confusing and unexpected since it is often in the middle of the main application and thus <strong>seems that it disappears</strong> until the user moves the main application to find it hiding behind.</li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/coLM3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/coLM3.jpg" alt="alt text"></a>
  </p>
  
  <p>This is the <strong>XAML</strong>:</p>
  
  <pre><code>&lt;Window x:Class="TestPopupFix.Window1"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="Window1" Height="600" Width="800"&gt;
      &lt;StackPanel&gt;
          &lt;Button Content="Open first popup" Click="Button_OpenFirst"/&gt;
          &lt;Button Content="Open second popup" Click="Button_OpenSecond"/&gt;
      &lt;/StackPanel&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>And this the <strong>code behind</strong>:</p>
  
  <pre><code>private void Button_OpenFirst(object sender, RoutedEventArgs e)
  {
      Window window = new Window();
      TextBlock tb = new TextBlock();
      tb.Text = "This is the first window.";
      window.Content = tb;
      window.Width = 300;
      window.Height = 300;
      window.Show();
  }
  
  private void Button_OpenSecond(object sender, RoutedEventArgs e)
  {
      Window window = new Window();
      TextBlock tb = new TextBlock();
      tb.Text = "This is the second window.";
      window.Content = tb;
      window.Width = 300;
      window.Height = 300;
      window.Show();
  }
  </code></pre>
  
  <p><strong>What do I have to do to make the main application stay furthest to the back as I pop up new windows?</strong></p>