[API Suggestion] Consider Control/Window Cloaking During Initialization #13233
Labels
a11y-WCAG2.2
api-suggestion
(1) Early API idea and discussion, it is NOT ready for implementation
area-DarkMode
Issues relating to Dark Mode feature
Milestone
TL;DR
Implement a cloaking mechanism for WinForms controls during initialization to eliminate jarring visual flashes, particularly critical for dark mode users and those with photosensitivity. This approach leverages Windows DWM cloaking flags to keep controls hidden until fully themed and ready, significantly improving accessibility compliance and user experience across all applications.
Rationale
The current WinForms runtime suffers from momentary visual flashing when controls are created or initialized. This occurs because the Desktop Window Manager (DWM) applies default white rendering before the application can override with themed styling. For users with dark mode enabled or those with photosensitivity conditions, this creates an uncomfortable white flash effect. (I am target-audience here, it REALLY does!!)
This issue represents both a user-experience-problem and a significant accessibility concern. Visual flashing during UI transitions can trigger adverse reactions in users with photosensitive epilepsy, migraines, or visual processing sensitivities. Modern accessibility standards (WCAG 2.1) explicitly recommend avoiding content that flashes to prevent these issues.
Similar problems were previously resolved in Windows components like File Explorer and addressed in Chromium-based browsers, demonstrating that this issue is recognized and solvable at the platform level. The WinForms runtime should implement an equivalent solution to ensure consistent visual experiences, especially for dark mode and high-contrast scenarios.
30,000-Feet View of the principal Approach
I propose implementing a standardized cloaking mechanism in the WinForms runtime that would:
Temporarily make controls/windows invisible during initialization using DWM cloaking flags, either by a global setting which leads to that behavior implicitly, or with a per-instance-approach by changing certain behaviors on control itself.
TBD: Scope of cloaking/duration of cloaking:
a) Only Pre-Filling background
b) Whole initialization process:
New APIs on Application
An additional setting similar to the
SetHighDpiMode
method or theHighDpiMode
property on Application:Application.SetCloakControlsMode(Never|Always|TypeBased|InstanceBased)
with its default as backwards compatible:Never
.For the Options
CloakControlsMode.TypeBased
andCloakControlsMode.InstanceBased
we would need a global event handler based on Application (rough idea):The EventArgs needed:
Then, the individual decision for cloaking a type for example, could look something like this:
By implementing this enhancement, the .NET WinForms runtime would significantly improve the experience for users of dark mode and those with accessibility needs, bringing it in line with modern UI framework expectations and accessibility standards.
There are several approaches then for the actual cloaking approach on windows level, which are under investigation and subject for follow-ups and amendments.
Why not just having a respective
CloakOnInit
property on Control?Sounds way easier right? Just implement it ambient, and we would be done.
Well, I think the problem is the way, that the WinForms Desiger's CodeDOM serialization has been originally ... designed. Namely, the order in which properties should be set, must not matter, except where it is absolutely necessary in which cases, we'd need to use
ISupportInitialization
. And that does not fly to retro-fit on control AT ALL.List of new APIs
TBD.
The text was updated successfully, but these errors were encountered: