3.4 KiB
3.4 KiB
description, applyTo
| description | applyTo |
|---|---|
| Accessibility requirements for interactive controls, keyboard navigation, screen readers, and contrast | **/*.cs, **/*.xaml |
Accessibility
These rules apply to every UI change. They are not optional add-ons.
Rules
- Every interactive control must have an
AutomationProperties.NameorAutomationProperties.LabeledBy. - Add a stable, unique
AutomationProperties.AutomationIdfor controls targeted by UI automation tests (and for key interactive elements). - Use semantic XAML controls — prefer
Button,HyperlinkButton,ListViewover styledBorder/Gridwith click handlers. - Ensure keyboard navigation works for all features:
- Logical tab order via
TabIndex. AccessKeybindings for frequently used actions.KeyboardAcceleratorfor shortcut keys.
- Logical tab order via
- Maintain minimum contrast ratios (4.5:1 for normal text, 3:1 for large text) — test in High Contrast mode.
- Support screen readers (Narrator / NVDA): test that all content is announced correctly.
- Images must have
AutomationProperties.Namedescribing the image purpose (orAutomationProperties.AccessibilityView="Raw"for decorative images). - Do not rely on colour alone to convey meaning — add icons, text, or patterns.
Anti-patterns
- Clickable
TextBlockorImagewithoutAutomationProperties. - Custom controls that are not keyboard-focusable.
- Using
Visibility.Collapsedto "hide" content from screen readers (useAccessibilityViewinstead).
Validation
- Build & register the MSIX package — see Build, Run & Deploy in
.github/agents/Agents.md. - Test keyboard navigation: tab through every new/changed UI area.
- Test High Contrast: switch to Windows High Contrast theme and verify readability.
- Run Accessibility Insights for Windows on the app.
Verification Checklist
- All interactive controls have
AutomationProperties.Name - Keyboard navigation works for the changed area
- Tested with High Contrast theme enabled
- Tab through the entire UI with keyboard only.
- Verify key interactive controls have stable, unique
AutomationProperties.AutomationIdvalues (especially controls used by UI automation tests). - Switch to Windows High Contrast theme and verify readability.
- Run Narrator and verify all controls are announced correctly.
- Run Accessibility Insights for Windows on the app.
Must Read & Research
Agent Rule: Before any accessibility-related change, you must fetch and review these references using
fetch_webpage. Apply what you learn.
| # | Reference | When to consult |
|---|---|---|
| 1 | Accessibility in WinUI | Any UI change — verify accessibility approach |
| 2 | AutomationProperties | Adding or modifying interactive controls |
| 3 | Accessibility Insights | Testing tool — run before finalizing UI changes |
| 4 | Keyboard Accessibility | Adding navigation, focus management, or shortcut keys |
| 5 | High Contrast Themes | Adding custom styles, colours, or theme resources |