Closing child window minimizes parent Closing child window minimizes parent wpf wpf

Closing child window minimizes parent


Why is it minimizing and how can I stop it?

Not sure about the "Why" maybe you can report it as a bug and see what they reply with as with a non-modal dialog you do not expect this to happen.

As for a workaround, Try something like this:

public partial class MainWindow : Window {  ...  protected override void OnMouseDoubleClick(MouseButtonEventArgs e) {    base.OnMouseDoubleClick(e);    var x = new SomeDialog { Owner = this };            x.Closing += (sender, args) => {      var window = sender as Window;      if (window != null)        window.Owner = null;    };    x.Show();  }}

^^ This should prevent the MainWindow(parent) from minimizing when SomeDialog is closed.


My workaround for this interesting problem is to activate the MainWindow once and after that activate the SomeDialog window again.

class SomeDialog : Window{    protected override void OnMouseDoubleClick(MouseButtonEventArgs e)    {        base.OnMouseDoubleClick(e);        new CustomMessageBox().ShowDialog();        Owner.Activate();        Activate();    }}


A very late answer... I just sat having this same issue and Viv's workaround solved it for me aswell. As for the "Why" part of the answer, i believe it happens when your child window spawns a child window of its own in its lifetime. For my experience it occured whenever pressing my Save button, which is in a flow which requires a child window to be opened. But pressing the Cancel (or escape) or the windows default quit button did not invoke the issue.