Skip to content

What's new in Windows Forms for .NET 11 #14771

Description

@KlausLoeffelmann

What's new in Windows Forms for .NET 11

This issue is the single-source technical outline for the .NET 11 Windows Forms work tracked by the .NET 11 API epic. It is intended to be lifted into release notes, documentation, and a later blog post. The descriptions below are factual; customer-facing narrative can be added when those documents are produced.

The implementation is staged in the Net11Api_* branches of KlausLoeffelmann/winforms and consolidated on Net11/Integration-3.

Application and system visual settings

Tracked by #14583.

SystemVisualSettings

Application.SystemVisualSettings exposes an immutable snapshot of Windows visual and accessibility state used by renderers:

  • Windows accent color.
  • Accessibility text-scale factor.
  • High Contrast state.
  • Client-area animation state.
  • Keyboard-cue visibility.
  • Focus-border metrics.

The unified Application notification reports the old and new snapshots plus the changed categories. Controls receive the same transition through a protected instance path that cascades through the parented control tree without adding per-control subscriptions. This gives in-box and vendor controls one leak-free route for repaint and metric updates.

VisualStylesMode opt-in

Application.SetDefaultVisualStylesMode(...) sets the process-wide default before controls are created. Application.DefaultVisualStylesMode exposes that default. Control.VisualStylesMode is ambient: an unset control inherits from its parent, or from the Application default at the top level.

The modes are:

  • Classic: conservative WinForms rendering.
  • Disabled: visual styles disabled.
  • Net11: .NET 11 renderer behavior.
  • Latest: newest available renderer behavior.
  • Inherit: assignment sentinel for returning a control to ambient behavior.

Control.EffectiveVisualStylesMode is the renderer-authoritative protected value. High Contrast always clamps effective rendering to classic, backward-compatible painting (unless visual styles are explicitly disabled). Modern renderers and adapters therefore do not need independent High Contrast branches.

The API and renderer proposal is tracked by #14587 and the earlier design discussion in #7641.

Change-impact model for control authors

A protected VisualStylesMode change-impact model lets a derived control describe the work required when its effective renderer changes:

  • None: no visual or layout work.
  • Repaint: client repaint only.
  • NonClientUpdate: non-client refresh without metric changes.
  • Metrics: preferred-size or layout metrics changed.

GetVisualStylesModeChangeImpact(oldMode, newMode) feeds the base OnVisualStylesModeChanged dispatcher. Metric transitions clear preferred-size caches and coalesce layout requests across the affected subtree so containers measure children only after the complete transition. High Contrast changes enter the same dispatcher with immutable old/new effective modes.

Control.OnSystemVisualSettingsChanged(...) provides category-aware system transitions to derived and vendor controls. Accent changes normally repaint; text-scale and focus-metric changes can request layout.

Accessibility-driven API work

TreeView.NodeLeading

Tracked by #14584.

TreeView.NodeLeading provides opt-in, text-scale-aware leading for node rows. The implementation includes DPI resynchronization and tests for row-height behavior.

Flicker-free UI mutation and FormRevealMode

Tracked by #14585.

The mutation work adds explicit suspension hooks for layout, positioning, and painting so compound UI changes can be applied without intermediate visual states. FormRevealMode provides an ambient form reveal contract and is wired into the Visual Basic Application Framework. Painting suspension survives handle transitions and composes with layout-aware mutation.

KioskModeManager

Tracked by #14586.

KioskModeManager is a component for full-screen kiosk behavior, including taskbar handling, top-most state, configurable full-screen keyboard behavior, power-saving suppression, pointer auto-hide, wake-up notifications and commands, and monitor selection. Follow-up fixes cover StatusStrip dropdown placement, minimized monitor selection, and display-geometry refresh; see #14765.

Modernized control rendering

The renderers are selected only under an effective Net11-or-later mode. No new settable theme colors, radii, or fonts are introduced; colors and metrics come from existing control properties and Windows state.

Button, CheckBox, and RadioButton

  • Button uses modern Standard, Flat, and Popup renderers, including DPI-aware geometry, dark mode, accent-derived states, disabled contrast, focus treatment, images, and BackgroundImage clipping.
  • CheckBox and RadioButton use accent-aware modern glyph renderers with hover/focus animation.
  • Appearance.ToggleSwitch provides a two-state animated toggle renderer. For a two-state CheckBox, ToggleSwitch intentionally wins over FlatStyle.System because the native control cannot draw the requested appearance.
  • Shared animation timing uses an absolute Stopwatch schedule and per-UI-thread ownership without changing process-wide timer resolution.

Related rendering reports include #14753, #14757, #14759, #14760, and #14762.

TextBoxBase and UpDown controls

  • Single-line TextBoxBase controls reserve DPI- and text-scale-aware non-client chrome without reducing their client area.
  • Rounded Fixed3D, flat FixedSingle, and minimal None treatments share one internal metric family.
  • Focus borders use Windows focus metrics and accent color.
  • Existing scrollbars remain visible, and small fixed controls degrade to a flat frame rather than inverting their client rectangle.
  • NumericUpDown and DomainUpDown share the modern field geometry and focus treatment.

Related reports include #14755, #14756, #14761, and #14763.

GroupBox FlatStyle

FlatStyle Classic / High Contrast / Disabled Effective Net11+
Standard Classic etched frame Borderless rectangular surface with enlarged caption
Flat Classic flat frame Rounded Windows-accent outline with ambient-size inline caption
Popup Classic popup frame Windows-accent header band and bordered body
System Native BS_GROUPBOX Native BS_GROUPBOX; unchanged

Standard and Popup enlarge the caption, while Flat keeps the ambient size. A regular ambient font uses a real installed Semibold family when available; otherwise its weight is preserved. Font is never modified. Standard's caption-above-body design moves DisplayRectangle down, aligns text to Padding, and reserves more content space above than below; layout and paint consume the same metrics. Effective Net11 styles expose a fixed UI Automation Heading Level 2. High Contrast uses classic painting and does not expose the modern heading level.

ComboBox FlatStyle

FlatStyle Classic / High Contrast / Disabled Effective Net11+
Standard Native themed field Rounded field using the TextBoxBase color scheme
Flat Classic flat adapter Square field using the TextBoxBase color scheme
Popup Flat until hover Rounded Standard geometry with Windows-accent border
System Native Native; unchanged

Modern fields add one logical pixel of framework inset on top of the designer-visible public Padding. Non-Simple fields share metrics with an AutoSize, single-line BorderStyle.Fixed3D TextBox using equivalent effective padding. The EDIT child receives matching horizontal margins while the adapter owns the frame. Dropdown list HWNDs request small rounded corners on Windows 11 and retain existing dark-mode list theming. DropDownStyle.Simple remains an embedded composite control.

Layout guidance

Modern chrome can require more adornment space than classic chrome. Intrinsically sized or AutoSize controls grow so their client area remains usable. Multiline TextBox and RichTextBox are fixed-bounds exceptions: their bounds remain stable and their client area can shrink slightly.

Use TableLayoutPanel or FlowLayoutPanel for adaptive layouts. The guidance covers:

  • Anchor when a child consumes or aligns to container-determined size; Dock when the child should push container size.
  • Equal-width OK/Cancel buttons using an AutoSize two-column TableLayoutPanel.
  • Mixed TextBox/ComboBox rows without fixed heights.
  • GroupBox DisplayRectangle changes.
  • Live text-scale growth without control recreation.

See the .NET 11 VisualStyles layout guidance.

Notable fixes

ToggleSwitch with FlatStyle.System

#14754 is fixed by keeping supported ToggleSwitch controls owner-drawn and using control bounds for mouse-state invalidation instead of requesting an unsupported System adapter. A complete FlatStyle x Appearance x VisualStylesMode interaction matrix verifies that no combination throws.

VisualStylesMode.Inherit designer serialization

Designer serialization now operates on the raw PropertyStore value. Inherit emits no CodeDOM assignment, explicit values do, reset performs one ambient assignment, and round trips preserve whether the property is ambient rather than baking the resolved parent or Application value into generated code.

Implementation and validation

The integrated source and designer projects build cleanly with the Arcade build. WinForms, designer, primitives, analyzer, Visual Basic, and related unit suites pass. One existing System.Drawing.Common WMF boundary test remains DPI-sensitive on a 150 percent desktop and reports scaled dimensions rather than its 96-DPI golden.

Metadata

Metadata

Labels

NewApi-Net11Tracks issues for public APIs targeted for .NET 11.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions