docs(rules): add WPF accessibility and theming, trim WPF rules
A new WPF topic rule covers accessibility (AutomationProperties names and help text, keyboard access, visible focus, high contrast through SystemColors, automation peers for custom controls), DPI scaling in device-independent units with tests across scale factors and monitors, and the Fluent theme through ThemeMode on .NET 9 and later. The existing WPF rules lose about a quarter of their size by merging one-line generic bullets that the C# and shared rules already cover, while keeping the WPF-specific pitfalls. Duplicate async void and binding error guidance is merged, client secret handling defers to the client app security rule, the architecture rule asks to check .NET Framework versus .NET before using newer APIs, and the CommunityToolkit note states that partial properties require C# 14. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b6c33780c3
commit
df09ddeaa9
8 files changed
+69
-185
No files matched your search
@@ -0,0 +1,23 @@
|
||||
# WPF Accessibility, Scaling, and Theming
|
||||
|
||||
Apply these rules when building or changing WPF views, controls, styles, or themes. Load the UI/UX rules for general interface design; Windows conventions, not macOS ones, decide navigation, menus, and settings.
|
||||
|
||||
## Accessibility
|
||||
|
||||
* Give every interactive element without visible text an accessible name with `AutomationProperties.Name`, and add `AutomationProperties.HelpText` where the purpose is not obvious. Keep names in sync with the visible label or state.
|
||||
* Make every action reachable by keyboard: logical tab order, `AccessText` or access keys for important commands, and `IsDefault` and `IsCancel` on dialog buttons. Use `KeyboardNavigation` settings deliberately inside lists, toolbars, and custom containers.
|
||||
* Keep focus visible. Do not remove `FocusVisualStyle` without an equal replacement, and move focus deliberately when dialogs open and close.
|
||||
* Support high contrast: use `SystemColors` and theme resources instead of hard-coded brushes, and never convey state by color alone.
|
||||
* Give custom controls an `AutomationPeer` that exposes their role, name, and state, and check them with Narrator and an accessibility inspector.
|
||||
|
||||
## Scaling
|
||||
|
||||
* Lay out in device-independent units with `Auto` and star sizing; never assume 96 DPI or a fixed screen size.
|
||||
* Use vector icons or multi-resolution image assets so the UI stays sharp at every scale factor, and test at 100, 150, and 200 percent and when moving windows between monitors with different scaling.
|
||||
* For .NET Framework apps, confirm the app is configured for per-monitor DPI awareness before relying on crisp rendering across monitors.
|
||||
|
||||
## Theming
|
||||
|
||||
* On .NET 9 and later, prefer the built-in Fluent theme for new apps and redesigns: set `ThemeMode="System"` on the `Application` (or a `Window`) to follow the Windows light and dark setting, or `Light` or `Dark` where the product requires it. Do not switch an existing app's theme as a side effect of another task.
|
||||
* Define colors and brushes as theme-aware resources so light, dark, and high-contrast modes all work, and test each of them.
|
||||
* Follow Windows conventions for window chrome, menus, dialogs, and settings, and keep text in resources so it can be localized.
|
||||
Reference in new issue
Block a user