Repository navigation
Fix issue 15031: Disable NET11 VisualStylesMode for composite controls (ToolStrip, DataGridView, etc.) until NET11 layout modernization is completed - #15033
Conversation
…s (ToolStrip, DataGridView, etc.) until NET11 layout modernization is completed
There was a problem hiding this comment.
🟡 Changes recommended
The current OnParentVisualStylesModeChanged early-return path can suppress propagation/notifications when removing a local VisualStylesMode value changes the effective mode under coercion.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Disables modern VisualStylesMode rendering for composite controls (currently ToolStrip and DataGridView) by coercing Net11/Latest requests to Classic, and adds unit tests to lock in the expected effective-mode behavior and eventing.
Changes:
- Add per-control coercion hook (
GetSupportedVisualStylesMode) and override it inToolStrip/DataGridViewto forceClassicforNet11and newer modes. - Adjust
Controlvisual-styles inheritance / transition plumbing to account for coercion when determining effective-mode changes. - Add unit tests validating
ToolStrip/DataGridVieweffective mode isClassicunder modern requests and that parent modern-mode transitions do not raiseVisualStylesModeChangedwhen effective mode is unchanged.
File summaries
| File | Description |
|---|---|
| src/System.Windows.Forms/System/Windows/Forms/Control.cs | Adds supported-mode coercion hook and updates inheritance/transition logic to respect coerced effective modes. |
| src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips/ToolStrip.cs | Forces Net11/Latest requests to use Classic effective visual styles mode. |
| src/System.Windows.Forms/System/Windows/Forms/Controls/DataGridView/DataGridView.cs | Forces Net11/Latest requests to use Classic effective visual styles mode. |
| src/test/unit/System.Windows.Forms/System/Windows/Forms/ToolStripTests.cs | Adds tests ensuring modern requests result in Classic effective mode and no spurious change events. |
| src/test/unit/System.Windows.Forms/System/Windows/Forms/DataGridViewTests.cs | Adds tests ensuring modern requests result in Classic effective mode and no spurious change events. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15033 +/- ##
=============================================
Coverage 37.24166% 37.24166%
=============================================
Files 246 246
Lines 9774 9774
Branches 1029 1029
=============================================
Hits 3640 3640
Misses 5970 5970
Partials 164 164
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
@LeafShi1, @SimonZhao888, @ricardobossan ... and also everybody else - just asking: Should we quirk that with an AppContext switch? |
KlausLoeffelmann
left a comment
There was a problem hiding this comment.
Yes!!
Can't wait to see this live!!
Thanks a lot!
Did you misread that PR draft? It likely still needs further revision. |
…s (ToolStrip, DataGridView, etc.) until NET11 layout modernization is completed (#15033) - Fall back to Classic rendering for ToolStrip, MenuStrip, and DataGridView when Net11 visual styles are requested. - Add AppContext switches to opt these controls into Net11 rendering: > - System.Windows.Forms.ToolStripModernRendering > - System.Windows.Forms.DataGridViewModernRendering - Preserve visual-style inheritance and change-notification behavior for coerced modes. - ToolStrip, MenuStrip, and DataGridView use stable Classic rendering by default until their Net11 layout modernization is complete. - Applications can opt into Net11 rendering through the corresponding AppContext switches. - Existing applications retain their current behavior unless explicitly opted in.
…s (ToolStrip, DataGridView, etc.) until NET11 layout modernization is completed (#15033) ## Proposed changes - Fall back to Classic rendering for ToolStrip, MenuStrip, and DataGridView when Net11 visual styles are requested. - Add AppContext switches to opt these controls into Net11 rendering: > - System.Windows.Forms.ToolStripModernRendering > - System.Windows.Forms.DataGridViewModernRendering - Preserve visual-style inheritance and change-notification behavior for coerced modes. ## Customer Impact - ToolStrip, MenuStrip, and DataGridView use stable Classic rendering by default until their Net11 layout modernization is complete. - Applications can opt into Net11 rendering through the corresponding AppContext switches. - Existing applications retain their current behavior unless explicitly opted in.
…15114) Replays #15033 onto the corrected integration/11.0-RC2 branch based on release/11.0. This is prerequisite 11 of 11 in the ordered RC2 integration chain. ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/winforms/pull/15114)
…5143) ## Description Backport the selected .NET 11 Visual Styles fixes to release/11.0 for RC2. This PR consolidates the following previously reviewed fixes into a single backport: - #14853 - Fix editable control border color in NET11 visual styles - #14904 - Fix modern RadioButton glyph clipping in RTL layouts - #14910 - Fix GroupBox background image rendering in .NET 11 visual styles - #14865 - Fix CheckBox and RadioButton explicit BackColor handling in VisualStylesMode.Net11 - #14860 - Fix Button focus indicator when hosted on a TabPage - #14827 - Fix ComboBox rendering with DropDownStyle.Simple - #15019 - Fix setting VisualStylesMode to Classic in the Properties window - #14887 - Fix text clipping in controls such as TextBox and ComboBox - #14929 - Fix inherited ForeColor/BackColor updates for controls inside GroupBox - #14815 - Fix ToggleSwitch text overlap in RTL layouts - #15033 - Disable NET11 VisualStylesMode for composite controls until their layout modernization is completed - #15113 - Reinstate per\-state Net11 editable\-control border strokes - #15159 - Fix CheckBox and RadioButton render transparently over a parent GroupBox BackgroundImage in VisualStylesMode.Net11 - #15163 - Add design-time analyzer guardrails and shared analyzer test harness ## Customer Impact - Without these fixes, applications using the .NET 11 Visual Styles may encounter rendering, layout, color, RTL, and design\-time issues across several WinForms controls, including TextBox, ComboBox, Button, CheckBox, RadioButton, GroupBox, and ToggleSwitch. The changes also prevent NET11 VisualStylesMode from being applied to composite controls that are not yet ready for the new visual style behavior. - The design-time analyzer guardrails detect unsupported Designer-generated code patterns that can break designer loading or serialization, and provide actionable guidance without changing application runtime behavior. Individual diagnostics remain configurable. ## Regression Most of the changes in this backport address regressions or incorrect behavior identified during .NET 11 Visual Styles development and validation. #15113 introduces the updated per-state border styling for editable controls as part of the .NET 11 Visual Styles. The remaining changes fix rendering, layout, color, RTL, and design-time issues related to the new visual styles. #15163 does not address a shipped runtime regression. It introduces design-time analyzer guardrails and includes fixes for analyzer false positives, missed cases, and VB analyzer exceptions identified during development. The individual changes have been reviewed and validated in their original PRs, and the selected changes were also tested before this backport. ## Testing Each fix includes its corresponding tests and validation from the original PR. The selected fixes were also tested together to validate the combined RC2 changes before backporting them to release/11.0. ### Risk **Medium.** - The primary risk is in WinForms control rendering and layout under the .NET 11 Visual Styles, along with the newly added design\-time analyzer behavior. This backport includes both visual-style fixes and an intentional visual behavior change for editable\-control borders introduced by #15113. The affected areas include: - Editable control border rendering and state-specific border styling. - CheckBox and RadioButton colors, glyphs, and background rendering. - RTL layout for RadioButton and ToggleSwitch. - GroupBox background, color inheritance, and child-control rendering. - Button focus indicator rendering. - ComboBox layout and rendering. - Text layout and clipping in editable controls. - VisualStylesMode behavior at design time. - VisualStylesMode availability for composite controls. - Design-time analyzer diagnostics. Some diagnostics are enabled as errors by default and can fail builds containing unsupported Designer-generated code. The diagnostics remain individually configurable. The individual changes have been reviewed and validated in their original PRs, and the combined changes were tested together before this backport. ## Fix Backport the selected .NET 11 Visual Styles changes for RC2, including: - Introduce the new per-state border styling for editable controls. - Fix editable-control border colors and text rendering. - Fix CheckBox, RadioButton, and ToggleSwitch rendering, including RTL scenarios. - Fix GroupBox background rendering and inherited colors. - Fix Button focus indicator rendering. - Fix ComboBox layout and rendering. - Fix VisualStylesMode configuration in the Properties window. - Disable NET11 VisualStylesMode for composite controls that are not yet ready for the new visual styles. - Adds design-time analyzer guardrails and the shared analyzer test infrastructure
Fixes #15031
Proposed changes
Customer Impact
Regression?
Risk
Screenshots
Before
After
Screen.Recording.2026-09-08.164528.mp4
Screen.Recording.2026-09-08.164230.mp4
Test methodology
Accessibility testing
Test environment(s)
Microsoft Reviewers: Open in CodeFlow