using Windows.UI.Xaml.Automation;
myControl.SetValue(AutomationProperties.NameProperty, <The desired localized accessible name>);
Similarly, the AutomationProperties.LabeledByProperty could be set in code-behind.
4. Use a custom AutomationPeer
A custom AutomationPeer can be used to customize an element’s accessible properties and behaviors in a way that goes beyond what’s possible through the AutomationProperties class. (I talk about XAML’s AutomationPeers at Does your XAML UI support the Patterns that your customer needs?)
It is not expected that a custom AutomationPeer is required solely to add a useful accessible name to an element. But if an element already uses a custom AutomationPeer, then that custom AutomationPeer can supply an accessible name by overriding the GetNameCore() function. The following example shows the custom AutomationPeer returning a feature-specific property called AccessibleName in a custom control associated with the AutomationPeer.
protected overridestring GetNameCore()
{
return this.owner.AccessibleName;
}
Other posts in this series:
Giving your XAML element an accessible name: Part 1 Introduction
Giving your XAML element an accessible name: Part 2 – Set the AutomationProperties.Name
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-49289-3.html
才是最明智者