Silverlight: How to force a screen reader to read something?
Silverlight does a good job of making the automation tree accessible, but is there a way to programatically ask a screen reader to read something? Up until now I've been using:
AutomationPeer peer = FrameworkElementAutomationPeer.FromElement(element);
if (peer == null)
{
开发者_StackOverflow社区 peer = FrameworkElementAutomationPeer.CreatePeerForElement(element);
}
if (peer != null)
{
peer.RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged);
}
This works fine under the debug Silverlight runtime (ie if I launch IE from inside VS), but doesn't work if I launch IE outside Visual Studio (even when it's pointing to the same internal development server...). So is there another simple way to ask the screen reader to read something?
EDIT: it also works fine in MS Narrator, but not in NVDA... weird.
I think you have to actually set focus on the element itself. Screen readers track the focus then they read values based on what is focused. If you fire the AutomationFocusChanged event then it might detect that but go back to the same control it had previously.
精彩评论