dotnet / dotnet/wpf

The Child window displayed behind the main window, and then the child window is displayed again in front of the main window

Open
#2,761 0 comments 3 reactions 0 assignees View on GitHub
Bug
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .NET Core Version: 3.1.101
* Windows version: 1909 18363.592
* 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...)? Yes, but not sure.
* Security issues and bugs should be reported privately, learn more via our [responsible disclosure guidelines](https://github.com/dotnet/wpf/blob/master/README.md#reporting-security-issues-and-security-bugs).



**Problem description:**

I'm not sure if this is a VS issue or a WPF issue.

We can see that the child window is displayed first, then the child window is displayed behind the main window, and then the child window is displayed again in front of the main window.

The steps

1. Set MainWindows as follows

```xml
WindowStyle="None" AllowsTransparency="True"
WindowState="Maximized"
```

2. Add a button to main window

```xml

```

3. Show a child window when button clicked

```csharp
private void Button_OnClick(object sender, RoutedEventArgs e)
{
var window = new Window()
{
};

window.Show();
}
```

When we are using VisualStudio 2019 to debug and attach the process, we will find that the child window is displayed first, then the child window is displayed behind the main window, and then the child window is displayed again in front of the main window.

At this point if you don't have additional debugging in VisualStudio 2019, you won't see the child window flicker.

**Expected behavior:**

The child window can show in front of the main window.

**Minimal repro:**

[https://github.com/dotnet-campus/wpf-issues/tree/master/ChildWindowDisplayedAndThenBackToMainWindow](https://github.com/dotnet-campus/wpf-issues/tree/master/ChildWindowDisplayedAndThenBackToMainWindow )

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.