AutomationPeer.GetName AutomationPeer.GetName AutomationPeer.GetName AutomationPeer.GetName Method

Definition

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 technology when they represent your app's UI by interacting with the Microsoft UI Automation framework.

public : Platform::String GetName()
winrt::hstring GetName() const;
public string GetName()
Public Function GetName() As string

Returns

string string

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

Remarks

FrameworkElementAutomationPeer introduces behavior to GetName by providing an intermediate GetNameCore implementation. If an element has a value for the LabeledByMicrosoft UI 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.

See also