.NET version
.NET SDK:
Version: 10.0.100
Commit: b0f34d51fc
Workload version: 10.0.100-manifests.5fb86115
MSBuild version: 18.0.2+b0f34d51f
Did it work in .NET Framework?
Yes
Did it work in any of the earlier releases of .NET Core or .NET 5+?
Didn't check it.
Issue description
When showing a custom dialog-form from a "pop-up" in Windows Forms on .NET, the Z-Order behaves differently compared to .NET Framework. Specifically:
In .NET Framework, calling SetWindowPos with HWND_TOPMOST (-1) works as expected—the popup does not stay topmost permanently.
In .NET, the pop-up window remains topmost always, causing UI elements like color pickers or other dialogs to appear behind the pop-up.
This leads to incorrect layering and usability issues in scenarios where multiple pop-ups or dialogs are involved.
Steps to reproduce
WinFormsApp9_ZOrderSample.zip
In the attachments, you can find two projects:
WinFormsApp9 - it's .NET application
WindowsFormsApp1 - it's .NET FW application
To reproduce the issue:
- Run the .NET project
- Press
button1 - it will open a special pop-up window
- Press
button1 again - it will open Form, using the ShowDialog method. As you can see, this form shows behind the pop-up.