From wpf-dev-pack
Implements WPF UI Automation for accessibility using AutomationPeer and AutomationProperties. Enables screen reader support and testing tools in WPF apps.
How this skill is triggered — by the user, by Claude, or both
Slash command
/wpf-dev-pack:implementing-wpf-automationsonnetThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Implementing accessibility features using UI Automation framework.
Implementing accessibility features using UI Automation framework.
When implementing AutomationPeer for a CustomControl, ensure the control project is properly set up:
/configuring-wpf-themeinfo/authoring-wpf-controlsUI Automation Framework
├── Providers (Server-side)
│ ├── AutomationPeer (base class)
│ ├── FrameworkElementAutomationPeer
│ └── Custom AutomationPeers
├── Clients (Consumer-side)
│ ├── Screen readers (Narrator, JAWS)
│ ├── Testing tools
│ └── Custom automation clients
└── Automation Properties
├── AutomationProperties.Name
├── AutomationProperties.HelpText
└── AutomationProperties.LabeledBy
<!-- Name - primary identifier for screen readers -->
<Button Content="Submit"
AutomationProperties.Name="Submit form"/>
<!-- Name for image buttons (no text content) -->
<Button AutomationProperties.Name="Close window">
<Image Source="/Icons/close.png"/>
</Button>
<!-- HelpText - additional description -->
<TextBox AutomationProperties.Name="Email address"
AutomationProperties.HelpText="Enter your email in format [email protected]"/>
<!-- LabeledBy - reference to label element -->
<Label x:Name="UsernameLabel" Content="Username:"/>
<TextBox AutomationProperties.LabeledBy="{Binding ElementName=UsernameLabel}"/>
<!-- AcceleratorKey - keyboard shortcut hint -->
<Button Content="_Save"
AutomationProperties.AcceleratorKey="Ctrl+S"/>
<!-- AccessKey - mnemonic key -->
<Button Content="_File"
AutomationProperties.AccessKey="Alt+F"/>
<!-- ItemStatus - current state information -->
<ListBoxItem AutomationProperties.ItemStatus="Selected, 3 of 10"/>
<!-- ItemType - type description for list items -->
<ListBoxItem AutomationProperties.ItemType="Email message"/>
<!-- LiveSetting - for dynamic content updates -->
<TextBlock AutomationProperties.LiveSetting="Polite"
Text="{Binding StatusMessage}"/>
| Value | Description |
|---|---|
| Off | No announcements |
| Polite | Announce when user is idle |
| Assertive | Announce immediately |
namespace MyApp.Controls;
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
public class RatingControl : Control
{
public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(
nameof(Value), typeof(int), typeof(RatingControl),
new PropertyMetadata(0));
public int Value
{
get => (int)GetValue(ValueProperty);
set => SetValue(ValueProperty, value);
}
public int MaxValue { get; set; } = 5;
// Create custom AutomationPeer
protected override AutomationPeer OnCreateAutomationPeer()
{
return new RatingControlAutomationPeer(this);
}
}
public class RatingControlAutomationPeer : FrameworkElementAutomationPeer
{
public RatingControlAutomationPeer(RatingControl owner)
: base(owner)
{
}
private RatingControl RatingControl => (RatingControl)Owner;
// Return control type for screen readers
protected override AutomationControlType GetAutomationControlTypeCore()
{
return AutomationControlType.Slider;
}
// Return class name
protected override string GetClassNameCore()
{
return nameof(RatingControl);
}
// Return accessible name
protected override string GetNameCore()
{
var name = base.GetNameCore();
if (string.IsNullOrEmpty(name))
{
return $"Rating: {RatingControl.Value} of {RatingControl.MaxValue} stars";
}
return name;
}
// Return help text
protected override string GetHelpTextCore()
{
return "Use arrow keys to change rating";
}
}
Advanced: See ADVANCED.md for implementing automation patterns (IRangeValueProvider), raising automation events, keyboard navigation, and screen reader announcements.
| Pattern | Purpose | Example Controls |
|---|---|---|
| IInvokeProvider | Single action | Button, MenuItem |
| IToggleProvider | Toggle state | CheckBox, ToggleButton |
| ISelectionProvider | Contains selectable items | ListBox, ComboBox |
| ISelectionItemProvider | Selectable item | ListBoxItem |
| IRangeValueProvider | Numeric range | Slider, ProgressBar |
| IValueProvider | Text value | TextBox |
| IExpandCollapseProvider | Expand/collapse | TreeViewItem, Expander |
| IScrollProvider | Scrollable content | ScrollViewer |
Tools location:
Windows SDK → bin → [arch] → inspect.exe
Usage:
1. Run inspect.exe
2. Hover over UI elements
3. View automation properties
4. Verify Name, ControlType, Patterns
Windows + Ctrl + Enter: Toggle Narrator
Tab: Navigate forward
Shift + Tab: Navigate backward
Caps Lock + Up/Down: Read current item
npx claudepluginhub christian289/dotnet-with-claudecode --plugin wpf-dev-packBuilding accessible .NET UI. SemanticProperties, ARIA, AutomationPeer, testing tools per platform.
Guides adding screen reader support to .NET MAUI apps via SemanticProperties, heading levels, AutomationProperties, focus management, and gotchas for TalkBack, VoiceOver, Narrator.
Designs WinUI 3 UIs and reviews XAML for correctness, covering layout planning, control selection, Fluent Design, theming (Light/Dark/HighContrast), typography, spacing, brushes, accessibility, and data binding.