winforms
winforms copied to clipboard
Add AppContext switch to mirror Owner.TopMost for modal dialogs (restore .NET Framework‑like behavior)
Fixes #14101
Proposed changes
- Add an switch
System.Windows.Forms.MirrorTopMostForModalDialogs. When enabled,ShowDialogwill temporarily set the dialog asTopMostif its owner isTopMost, and restore the original state after closing. Default is false to keep current behavior.
Customer Impact
- With the switch off: No change, modern .NET behavior remains.
- With the switch on: Modal dialogs owned by
TopMostforms will stay above the owner during the modal session, matching .NET Framework behavior.
Regression?
- Yes
Risk
- Minimal
Screenshots
Before
If the owner is TopMost and the dialog is not, the dialog can be pushed behind the owner during the modal session.
After
Modal dialogs temporarily become TopMost when the owner is TopMost, and stay above the owner until closed.
Test methodology
- Manually
Test environment(s)
- .net 10.0.0-rc.3.25603.106
Microsoft Reviewers: Open in CodeFlow
Codecov Report
:x: Patch coverage is 25.00000% with 9 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 77.15426%. Comparing base (5d64bba) to head (8ff448e).
:warning: Report is 8 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #14138 +/- ##
===================================================
+ Coverage 76.01271% 77.15426% +1.14154%
===================================================
Files 3279 3279
Lines 645325 645337 +12
Branches 47720 47722 +2
===================================================
+ Hits 490529 497905 +7376
+ Misses 145491 143738 -1753
+ Partials 9305 3694 -5611
| Flag | Coverage Δ | |
|---|---|---|
| Debug | 77.15426% <25.00000%> (+1.14154%) |
:arrow_up: |
| integration | 18.98449% <25.00000%> (?) |
|
| production | 52.01885% <25.00000%> (+2.55940%) |
:arrow_up: |
| test | 97.40749% <ø> (ø) |
|
| unit | 49.47059% <25.00000%> (+0.01114%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.