Repository navigation
Description
Rationale
WinForms needs a versioned Visual Styles path that allows accessibility-driven rendering improvements to ship without breaking existing pixel-perfect applications. The feature should be opt-in, predictable, and specific to WinForms visual rendering rather than becoming a general theming system.
Classic CheckBox controls give users a very small practical landing area and use a design language that many customers no longer accept as modern. That matters for accessibility: small glyph-focused targets are harder for touch, pen, low-vision users, and users with motor impairments. Modern checkbox rendering should increase the practical hit target, make the state easier to recognize, and keep compatibility through explicit visual-style versioning.
RadioButton controls, also known as option buttons, have the same landing-area and visual-language problem. Since WinForms has already introduced new renderers for Button, extending the overhaul to the whole button family is a lower-risk and more coherent path than modernizing each control independently. The normal Button should also receive a .NET 11 visual style based on current Fluent Design styling, including rounded corners.
TextBoxBase is missing an effective Padding API. This is also an accessibility issue in dense forms. In particular, dark surfaces make the problem more visible: a white TextBox border on a dark background creates a much stronger contrast boundary than the complementary classic/light appearance. In forms with many Label/TextBox pairs, users can lose track of grouping and reading flow. Versioned Visual Styles give WinForms a compatibility-safe way to modernize TextBox rendering, expose padding, and improve spacing without forcing layout changes on existing applications.
What this feature is and is not
- We have NO intention to introduce full-blown theming support in WinForms with this.
- We want to be very mindful with this topic, since there are a lot of theming standards already out there.
- The API is meant as an opt in: You can use it, but if you do not, nothing should break. Existing theming concepts should continue to work as they are.
Versioning Visual Styles for current and future A11Y requirements
Visual Styles Mode versions how controls render in different .NET releases. This is essential for backward compatibility when accessibility requirements or platform design expectations require larger minimum sizes, different padding, different margins, updated hit testing, or updated border rendering.
In .NET 11, the first versioned Visual Styles target is Net11. Applications that do not opt in keep existing rendering. Applications that do opt in can use the .NET 11 rendering contract directly, use Latest to follow the latest stable Visual Styles contract, or use LatestPreview when they intentionally want preview/out-of-band Visual Styles behavior before it is promoted into a stable version.
The APIs are added to Application and Control, with VisualStyles in their names, so both new and existing applications can opt into enhanced rendering while maintaining compatibility with previous framework versions.
API Proposal
namespace System.Windows.Forms;
public enum VisualStylesMode : short
{
Inherit = -1,
Classic = 0,
Disabled = 1,
Net11 = 2,
Latest = short.MaxValue,
}namespace System.Windows.Forms;
public static partial class Application
{
public static VisualStylesMode VisualStylesModeDefault { get; }
public static void SetVisualStylesModeDefault(VisualStylesMode visualStylesMode);
}namespace System.Windows.Forms;
public partial class Control
{
public VisualStylesMode VisualStylesMode { get; set; }
public event EventHandler? VisualStylesModeChanged;
protected virtual void OnVisualStylesModeChanged(EventArgs e);
// Allows a derived control to set a particular Visual Styles mode for compatibility reasons.
protected virtual VisualStylesMode DefaultVisualStylesMode { get; }
}namespace System.Windows.Forms;
public abstract class TextBoxBase : Control
{
public new Padding Padding { get; set; }
}namespace System.Windows.Forms;
public enum Appearance
{
Normal = 0,
Button = 1,
ToggleSwitch = 2,
}Namespace Microsoft.VisualBasic.ApplicationServices
Public Class ApplyApplicationDefaultsEventArgs
Inherits EventArgs
Public Property VisualStylesMode As VisualStylesMode
End Class
End NamespaceThe VB Application Framework wiring completes work anticipated back in the .NET 9 Visual Styles attempt: WindowsFormsApplicationBase.OnInitialize already carries a comment stating that HighDpiMode, ColorMode, and VisualStylesMode are fed to ApplyApplicationDefaultsEventArgs, but only HighDpiMode/ColorMode were ever actually wired up. This closes that gap, following the exact same shadow-instance-field pattern already used for ColorMode/HighDpiMode (WindowsFormsApplicationBase keeps its own _visualStylesMode field, seeded independently of Application.DefaultVisualStylesMode, and applies it via Application.SetDefaultVisualStylesMode once at the end of OnInitialize - the only call site that ever touches the static setter in the supported flow, so SetDefaultVisualStylesMode's write-once semantics are not at risk of a spurious double-set).
API Usage
Application.SetDefaultVisualStylesMode(VisualStylesMode.Net11);
Application.Run(new MainForm());Application.SetDefaultVisualStylesMode(VisualStylesMode.LatestPreview);
Application.Run(new VisualStylesPreviewForm());checkBox1.VisualStylesMode = VisualStylesMode.Net11;
checkBox1.Appearance = Appearance.ToggleSwitch;
textBox1.VisualStylesMode = VisualStylesMode.Net11;
textBox1.Padding = new Padding(8, 4, 8, 4);Risks - limited, only when opted in
- Updated control metrics WILL affect pixel-perfect layouts.
- Rendering, hit testing, focus cues, UIA bounds, and keyboard behavior must stay aligned for the button family.
TextBoxBase.PaddingWILL change layout expectations for derived controls and must be constrained to Visual Styles modes where the new rendering contract applies.- Owner-drawn controls, custom renderers, and inherited controls must have clear compatibility behavior.
Will this feature affect UI controls?
Yes. This feature intentionally affects rendering, spacing, and practical hit targets for selected controls when the application or control opts into a Visual Styles mode beyond classic behavior. The initial focus is the button family and TextBoxBase-derived controls:
- CheckBox
- RadioButton
- Button
- TextBox
- RichTextBox
- NumericUpDown
Designer support is expected for localized property categories/descriptions and CodeDOM serialization-safe defaults. Existing applications that do not opt in should preserve their current rendering and layout behavior.
Status Checklist
- API proposal has
api-suggestionlabel - Rationale, API Proposal, API Usage, and Risks sections are complete
- API shape has been discussed with the team
- Review the issue for compatibility with what the API review board expects
- API review completed — label changed to
api-approved(So done in the original item [API Suggestion] Introduce Modern Visual Styles for Apps targeting .NET 11+ and Win 11+ for A11Y improvements. (Was DarkMode/VisualStyles) #7641)
Work tracker
- Create Visual Styles only issue based on the original upstream dark-mode/Visual Styles issue: [API Suggestion] Introduce Modern Visual Styles for Apps targeting .NET 11+ and Win 11+ for A11Y improvements. (Was DarkMode/VisualStyles) #7641.
- Explore
HighPrecisionTimeroption as an animation trigger based on process-limitedtimeBeginPeriodbehavior. Windows 10 version 2004 and later no longer apply a caller's requested timer resolution globally; earlier versions used a global timer-resolution setting. - Add
VisualStylesMode.Inheritambient sentinel for designer serialization. - Extend the VB Application Framework (
ApplyApplicationDefaultsEventArgs.VisualStylesMode) - API proposed above, tracked in [Epic] .NET 11 new WinForms API surface (accessibility-driven) #14694. - Explore option for non-client rendering in
Controlper se. - Extract useful, approved code from the .NET 9 PRs and port what still makes sense to .NET 11.
- Create exploratory test app to test new Visual Styles in combination with the new
KioskModeManagerAPIs ([.NET 11 API Proposal] Introduce KioskModeManager component #14586) and improved layout APIs ([.NET 11 API Proposal] Add APIs for performance improved, flicker-free WinForms UI mutation #14585). - Have tests done by test team.
Activity
[-][.NET 11 API Proposal] Visual Styles feature[/-][+]Visual Styles feature (postponed from .NET 9 and .NET 10)[/+][-]Visual Styles feature (postponed from .NET 9 and .NET 10)[/-][+][NET11 new API] Visual Styles feature (postponed from .NET 9 and .NET 10)[/+]KlausLoeffelmann commentedon Jul 18, 2026
Amendment (post-implementation): change-impact model and EffectiveVisualStylesMode visibility
This extends the originally approved surface. Implementation showed that base
OnVisualStylesModeChangedperformed no preferred-size cache invalidation and no layouttransaction, unlike
OnFontChanged. Every metric-changing control therefore had toreimplement a four-step, ordering-critical protocol.
The concrete motivating bug was
TextBoxBaserunning parent layout beforeUpdateStyles(), so containers measured pre-transition metrics and live mode switchescould clip until control recreation. A top-level switch also triggered one full parent
layout per affected control—O(controls × containers)—against partially transitioned
state.
Addition A —
EffectiveVisualStylesModeEffectiveVisualStylesModechanges fromprivate protectedtoprotectedand remainsnon-virtual. Custom controls must render against the effective value because the raw
VisualStylesModedoes not include the High Contrast or Disabled clamp.Non-virtual is deliberate: this property is the accessibility policy enforcement point.
The customization hook remains virtual
DefaultVisualStylesMode, upstream of the clamp.Addition B — impact declaration
Derived controls declare what changes; the base class owns how and in what order to
react. The default
Repaintmakes custom controls correct without imposing layout cost.Metric changes now produce one coalesced layout pass per container after the complete
subtree has transitioned, so the ordering bug is structurally impossible.
Behavioral note
Base
OnVisualStylesModeChangedis now the dispatcher. It early-outs when the effectivemode is unchanged, clears caches and updates styles/non-client state according to the
declared impact, and coalesces child transitions and layout. Existing overrides that call
baseinherit this behavior. The change is recorded indocs/Net11Api_05_VisualStylesMode.HighRiskReview.md.Expected Questions
Q: Why isn't
EffectiveVisualStylesModevirtual?A: It is the accessibility enforcement point (High Contrast ⇒
Classic,Disabledhonored). Avirtual authoritative property is a contradiction — derived controls could silently break the HC
guarantee for exactly the users it protects. The supported customization point is the virtual
DefaultVisualStylesMode, upstream of the clamp.Q: Why an enum + virtual method instead of an
ExtendedStatesbit (theUserPreferredSizeCachepattern)?
A: Impact has four levels, not two, and is pair-dependent:
Classic→Net11may beMetricswhileNet11→LatestisRepaintfor the same control. A static bit cannot express either.Q: Why is the default
Repaintrather than the conservativeMetrics?A:
Repaintis the safe and cheap default: a control that doesn't override gets correct renderingwith no layout cost. Defaulting to
Metricswould tax every existing custom control with fulllayout passes on every switch to protect a case (metrics changing without the author knowing) that
implies deeper bugs anyway.
Q: Is the new base-class behavior a breaking change for existing
OnVisualStylesModeChangedoverriders?
A: The API is new in this release; no stable-release overriders exist. Within the release, the change
is documented in the high-risk review notes, and the amendment removes work from overriders rather
than adding requirements.
Q: Why does
Application.SetDefaultVisualStylesModenot followSetCompatibleTextRenderingDefault("Default" last)?
A: Modern precedent is
SetHighDpiMode(3.0),SetDefaultFont(6),SetColorMode(9);SetDefaultFontplaces Default first. Decisively, the method pairs with the actual propertyApplication.DefaultVisualStylesModeand mirrors its name.SetCompatibleTextRenderingDefault(NetFx 2.0) has no corresponding
Applicationproperty; its grammar does not transfer. Consideredand rejected.
KlausLoeffelmann commentedon Jul 29, 2026
Merged into main and Preview7.