AutomationProperties.Name attached property

Applies to Windows and Windows Phone

Gets or sets the UI Automation name of the element.


<object AutomationProperties.Name="nameString" />

XAML Values

nameString

The name of the element. This should be a human-readable name, assistive technologies often use this name string in their behavior.

Remarks

AutomationProperties.Name is an attached property, which supports a XAML usage. When getting this property in code, use GetName. When setting this property in code, use SetName instead. In code usages, the target parameter is the object where the attached property value is set. Another way to get or set the value in code is to use the dependency property system, calling either GetValue or SetValue and passing NameProperty as the dependency property identifier.

The purpose of AutomationProperties.Name and the AutomationProperties attached properties is to provide instance values for behavior that are not already present or defined in the control definition or a control's applied generic template.

AutomationProperties.Name is the most likely automation property to be picked up by UI Automation clients. The default peer implementations for most UI controls include logic that attempts to walk into the automation tree to find text content, and to use that text content as a control-generated default for AutomationProperties.Name. For example, a default instance of a Button control uses a ButtonAutomationPeer peer. This peer implements a behavior that promotes any inner text found within the button content to be the Name property value for UI Automation. Therefore, before routinely setting AutomationProperties.Name on all UI elements, you might want to test the UI Automation structure at run time first. If you use the default peer behavior, you can often take advantage of other mechanisms that are already in place. For example, if a Binding is used to set the Content of a Button, the dynamic run-time behavior of the automation peer can use the evaluated binding that might be using localized strings and resource dictionaries, so that there is no need to separately localize the AutomationProperties.Name value. For more info, see Exposing basic information about UI elements.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Automation

Metadata

Windows.winmd

See also

AutomationProperties
Exposing basic information about UI elements

 

 

Show:
© 2014 Microsoft