GetName method
Collapse the table of content
Expand the table of content

AutomationPeer.GetName method

Gets text that describes the element that is associated with this automation peer. The Microsoft UI Automation Name value is the primary identifier used by most assistive technologies when they represent your app's UI by interacting with the UI Automation framework.


Public Function GetName() As String


This method has no parameters.

Return value

Type: System.String [.NET] | Platform::String [C++]

The name of the element that is the peer's owner, as used by assistive technologies and other UI Automation clients.


FrameworkElementAutomationPeer introduces behavior to GetName by providing an intermediate GetNameCore implementation. If an element has a value for the LabeledByUI Automation property, the labeling element's Name value is used as the Name.

FrameworkElementAutomationPeer also introduces behavior through an internal GetPlainText method that other default peer classes may override in order to access the content model of that control and return a useful default for Name. For example, any ContentControl derived class will use a string representation of its Content value as the default Name. This is enabled because internally ContentControl implements GetPlainText and imparts that behavior to all ContentControl derived classes. This is how you get a useful Name default from the string value of a Button, for example.

Other specific peers also may have an intermediate GetNameCore implementation that provides a useful way for that particular Windows Runtime control to provide built-in values for Name. The source of these values comes from other UI properties that are typically set in XAML or as app user code. For example, TextBoxAutomationPeer implements behavior that uses the value of the Text property from the owner TextBox as the default Name. From the user code perspective, the default behavior can be overridden by applying a different AutomationProperties.Name value. From the peer implementer / provider perspective, the default behavior of the peer can be changed by deriving a new peer class from the existing peer, overriding GetNameCore, and giving it a new implementation that wouldn't call the base implementation in at least some cases.

To learn more about the possible default behavior of specific peer classes for default Windows Runtime controls, see the reference topic for that particular peer class and look for implementation notes in the Remarks section.

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0


Windows::UI::Xaml::Automation::Peers [C++]



Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]


Windows::UI::Xaml::Automation::Peers [C++]



See also

Custom automation peers



© 2016 Microsoft