title: Closing child window minimizes parent
body: <p>The following code demonstrates an issue I'm having where closing a child window minimizes the parent window, which I dont want to happen.</p>
  
  <pre><code>    class SomeDialog : Window
      {
          protected override void OnMouseDoubleClick(MouseButtonEventArgs e)
          {
              base.OnMouseDoubleClick(e);
              new CustomMessageBox().ShowDialog();
          } 
      }
  
      class CustomMessageBox : Window
      {
          public CustomMessageBox()
          {
              Owner = Application.Current.MainWindow;
          }
      }
  
      public partial class Window1 : Window
      {
          public Window1()
          {
              InitializeComponent();
          }
  
          protected override void OnMouseDoubleClick(MouseButtonEventArgs e)
          {
              base.OnMouseDoubleClick(e);
              new SomeDialog() { Owner = this }.Show();
          }
      }
  </code></pre>
  
  <p>Window1 is the main application window. </p>
  
  <p>SomeDialog is a window that pops up on some event within Window1(double clicking window1 in the example) that needs to be <strong>modeless</strong>.</p>
  
  <p>CustomMessageBox is a window that pops up on some event within "SomeDialog" (double clicking SomeDialog in the example) that needs to be <strong>modal</strong>.</p>
  
  <p>If you run the application, and then double click Window1's content to bring up SomeDialog, and then you then double click SomeDialog's content to bring up the CustomMessagebox.</p>
  
  <p>Now you close CustomMessagebox. Fine.</p>
  
  <p>Now if you close SomeDialog, Window1 minimizes? Why is it minimizing and how can I stop it?</p>
  
  <p><strong>Edit</strong> : It appears the workaround is rather simple, using the technique suggesrted by Viv.</p>
  
  <pre><code>class SomeDialog : Window
      {
          protected override void OnMouseDoubleClick(MouseButtonEventArgs e)
          {
              base.OnMouseDoubleClick(e);
              new CustomMessageBox().ShowDialog();
          }
  
          protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
          {
              base.OnClosing(e);
              Owner = null;
          }
      }
  </code></pre>