How to prevent the parent window from closing in the background after the child window is closed?

So, I had a problem with many of my WPF applications, where after closing the child windows, this window (usually my main window) will depend on the background, for something else that I have. After some research, I found this bug report submitted by Microsoft: Bug Report and their usual answer "The WPF team recently addressed this issue and will not solve it ..."

Has anyone successfully dealt with this? It drives me crazy and I can't find a solution.

EDIT:

I thought about what James recommended in his answer, and after almost rejecting his proposal due to the inconvenient nature of the window, which is on top of everything else, I came up with this:

ChildWindow.Closed += delegate
{
    ChildWindow = null;
    this.Topmost = true;
    System.Threading.Thread.Sleep(1000);
    this.Topmost = false;
};

, Closed() , , . 1 false, .

: this.Topmost = true, this.Topmost = false, , - .

, , . Microsoft WPF.

+4
2

:

Topmost=true

, . , , . , .

+2

, . , , , , , Focus() , , , :

ChildWindow.Closed += delegate
{
    ChildWindow = null;
    parentWindow?.Focus();
};
0

Source: https://habr.com/ru/post/1527430/


All Articles