Fix setting VisualStylesMode to Classic in the Properties window - #15019
Open
LeafShi1 wants to merge 2 commits into
Open
Fix setting VisualStylesMode to Classic in the Properties window#15019LeafShi1 wants to merge 2 commits into
LeafShi1 wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adjusts Control.VisualStylesMode’s ambient/local override behavior so that explicitly assigning a value (e.g., Classic) remains a local override even when it matches the current parent-resolved value, fixing WinForms Designer property-grid reversion/serialization for Classic.
Changes:
- Update
Control.VisualStylesModesetter to only clear the local value whenVisualStylesMode.Inheritis explicitly assigned. - Add a unit test that uses
PropertyDescriptor.SetValueto validate that setting a value matching the parent preservesShouldSerializeValue.
File summaries
| File | Description |
|---|---|
| src/System.Windows.Forms/System/Windows/Forms/Control.cs | Changes the VisualStylesMode setter’s logic for when to remove the local override. |
| src/test/unit/System.Windows.Forms/System/Windows/Forms/ControlTests.VisualStylesMode.cs | Adds a regression test covering property-grid style setting when the value matches the parent. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
LeafShi1
force-pushed
the
Fix_15012_VisualStylesMode_cannot_be_changed_to_Classic
branch
from
September 1, 2026 08:31
4006e82 to
fac2b0b
Compare
LeafShi1
force-pushed
the
Fix_15012_VisualStylesMode_cannot_be_changed_to_Classic
branch
from
September 2, 2026 06:06
fac2b0b to
e9e04ac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #15012
Root Cause
The
VisualStylesModesetter removed the local value when it matched the parent’s resolved mode. In the designer, settingClassicmatched the ambient parent value, so the override was removed and the property reverted to Inherit.Proposed changes
VisualStylesMode.Inheritis explicitly assigned. Preserve explicitly assigned values even when they currently match the parent.Customer Impact
VisualStylesModeasClassicthrough the Visual Studio Properties window. Explicit values also remain stable if the parent’s visual styles mode later changes.Regression?
Risk
Screenshots
Before
Selecting Classic for
Form.VisualStylesModein the Properties window immediately reverted the property to Inherit and did not serialize the selection.BeforeChanges.mp4
After
Selecting
Classicpreserves and serializes the explicit value. SelectingInheritcontinues to remove the local override as expected.AfterChanges.mp4
Test methodology
Test environment(s)
Microsoft Reviewers: Open in CodeFlow