Wpf: Modal dialog on top of non-modal window sends main window to back

Created on 20 Apr 2020  路  3Comments  路  Source: dotnet/wpf

  • .NET Core Version: .NET 4.7
  • Windows version: win10
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
  • Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? No

    Problem description:
    Modal dialog on top of non-modal window sends main window to back. Ie, when we close a child window its Owner gets send back (we lost focus)

    Actual behavior:
    The parent window lost focus after closing a child window after closing a modal.

    Expected behavior:
    No matter if a modal dialog has been shown before, if a user closes a child window, the parent window should stay visible.

    Minimal repro:
    Here is the problem and some source code to reproduce: https://stackoverflow.com/questions/10757625/why-does-closing-the-last-child-window-minimize-its-parent-window

issue-type-bug

Most helpful comment

@lisberPontes Could you help me to check is it a same issue with #2761

Hi @lindexi , I'm afraid is not the same problem. I've restore a quick video showing the problem. Just to add some context about it:

  1. By clicking on an icon we open a child window (it's Owner is the Main Window)
  2. We raise a Dialog box
  3. We raise the .Close() on the Child Window, and by doing so the Main Window losses its focus.

ChildWindow_LostFocus_ParentWindow

All 3 comments

@lisberPontes Could you help me to check is it a same issue with https://github.com/dotnet/wpf/issues/2761

@lisberPontes Could you help me to check is it a same issue with #2761

Hi @lindexi , I'm afraid is not the same problem. I've restore a quick video showing the problem. Just to add some context about it:

  1. By clicking on an icon we open a child window (it's Owner is the Main Window)
  2. We raise a Dialog box
  3. We raise the .Close() on the Child Window, and by doing so the Main Window losses its focus.

ChildWindow_LostFocus_ParentWindow

@lisberPontes Thank you. And I also find this problem and I write a demo in wpf-issues/ChildWindows at master 路 dotnet-campus/wpf-issues

The MainWindow will lose focus when close the sub window in WPF.

Was this page helpful?
0 / 5 - 0 ratings