Accessibility Architecture
Avalonia’s accessibility system is based on:- AutomationProperties - Attached properties for metadata
- AutomationPeers - Expose controls to assistive technologies
- Platform Integration - Maps to native accessibility APIs
- Windows: UI Automation (UIA)
- macOS: NSAccessibility
- Linux: AT-SPI (Assistive Technology Service Provider Interface)
AutomationProperties
From~/workspace/source/src/Avalonia.Controls/Automation/AutomationProperties.cs:
Basic Properties
Available Automation Properties
Identity and Description:Name- Accessible name for the elementAutomationId- Unique identifier for automationHelpText- Detailed description or help textAccessKey- Keyboard access key (e.g., “Alt+F” for File menu)AcceleratorKey- Keyboard shortcut (e.g., “Ctrl+S” for Save)
ControlTypeOverride- Override the control typeClassNameOverride- Override the class nameAccessibilityView- Control visibility in automation tree
LabeledBy- Reference to labeling elementLiveSetting- Live region behavior (Off, Polite, Assertive)
LandmarkType- Semantic landmark (Banner, Main, Navigation, etc.)HeadingLevel- Heading level (1-6)PositionInSet- Position in a set of itemsSizeOfSet- Total number of items in set
IsOffscreenBehavior- How to handle offscreen stateIsControlElementOverride- Override control element visibility
Property Examples
Labeling Form Fields
Live Regions
Off- No announcements (default)Polite- Announce when user is idleAssertive- Announce immediately, interrupting speech
Landmarks
Banner- Site header/bannerMain- Main content areaNavigation- Navigation menuSearch- Search functionalityForm- Form regionComplementary- Complementary content (sidebar)ContentInfo- Footer/metadataRegion- Generic landmark region
Headings
Automation Peers
From~/workspace/source/src/Avalonia.Controls/Automation/Peers/AutomationPeer.cs:
Understanding AutomationPeers
Automation peers expose controls to assistive technologies. Each control has an associated peer that provides:- Control type and classification
- Current state and properties
- Available patterns (interactions)
- Hierarchical relationships
Control Types
Creating Custom Automation Peers
Implementing Automation Patterns
Common Automation Patterns
From~/workspace/source/src/Avalonia.Controls/Automation/Provider/:
IInvokeProvider- Invokable controls (buttons)IToggleProvider- Toggle controls (checkboxes)ISelectionProvider- Selection containers (list boxes)ISelectionItemProvider- Selectable itemsIValueProvider- Value controls (text boxes, sliders)IRangeValueProvider- Range controls (sliders, progress bars)IExpandCollapseProvider- Expandable controls (tree view items)IScrollProvider- Scrollable containers
Keyboard Navigation
Tab Navigation
TabIndex- Order in tab sequence (default: 0)IsTabStop- Include in tab navigation (default: true)
Access Keys (Mnemonics)
Keyboard Focus
Screen Reader Support
Announcing Dynamic Content
Status Updates
High Contrast Support
Detecting High Contrast Mode
Styling for High Contrast
Best Practices
General Guidelines
Form Accessibility
Interactive Elements
Lists and Trees
Images and Icons
Testing Accessibility
Manual Testing
-
Keyboard Navigation
- Tab through all interactive elements
- Verify logical tab order
- Test all keyboard shortcuts
- Ensure focus is visible
-
Screen Reader Testing
- Windows: NVDA or Narrator
- macOS: VoiceOver
- Linux: Orca
-
High Contrast Mode
- Enable system high contrast
- Verify all content is visible
- Check color contrast ratios
Automated Testing
Platform-Specific Considerations
Windows (UI Automation)
- Full UIA support
- Narrator integration
- NVDA and JAWS support
macOS (NSAccessibility)
- VoiceOver integration
- Accessibility API mapping
- Native control behavior
Linux (AT-SPI)
- Orca screen reader support
- AT-SPI bridge integration
- Requires
Avalonia.FreeDesktop.AtSpipackage
See Also
- Testing - Automated UI testing
- Styling and Theming - High contrast themes