Fix Counter Control accessibility: Enable Narrator announcements for value changes#1983
Fix Counter Control accessibility: Enable Narrator announcements for value changes#1983
Conversation
Co-authored-by: niels9001 <9866362+niels9001@users.noreply.github.com>
niels9001
left a comment
There was a problem hiding this comment.
This does not work. You might be missing
var peer = FrameworkElementAutomationPeer.FromElement(targetTextBlock) ?? FrameworkElementAutomationPeer.CreatePeerForElement(targetTextBlock);
peer?.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged);
Also don't update the tests, so just remove it.
Co-authored-by: niels9001 <9866362+niels9001@users.noreply.github.com>
Added the missing automation peer code to raise LiveRegionChanged events and removed the unit tests as requested. The implementation now includes: var peer = FrameworkElementAutomationPeer.FromElement(CountText) ?? FrameworkElementAutomationPeer.CreatePeerForElement(CountText);
peer?.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged);This ensures screen readers are properly notified when the counter value changes. Commit: 7ae6e33 Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
/azp run |
The Counter Control in the Custom & User Controls section was not announcing value changes to screen readers when users activated the "Increase" and "Decrease" buttons. While the counter value updated visually, Narrator remained silent, creating an accessibility barrier for users relying on assistive technology.
Root Cause
The
CounterControlonly updated theTextBlock.Textproperty without implementing proper accessibility patterns to notify screen readers of dynamic content changes.Solution
Added comprehensive WinUI accessibility support to enable live region announcements:
XAML Template Changes
The key addition is
AutomationProperties.LiveSetting="Polite"which marks the TextBlock as a "live region" that screen readers monitor for content changes.Code-Behind Implementation
Added proper automation peer handling to trigger screen reader announcements:
Enhanced Automation Names
Expected User Experience
This implementation follows Microsoft Accessibility Guidelines and uses standard WinUI accessibility patterns to ensure the Counter Control is fully accessible to screen reader users.
Fixes #1965.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.