Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
public ref class AutomationProperties sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)] /// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)] /// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)] class AutomationProperties final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)] [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)] [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)] public sealed class AutomationProperties
Public NotInheritable Class AutomationProperties
Object Platform::Object IInspectable AutomationProperties
Windows 10 (introduced in 10.0.10240.0)
Windows.Foundation.UniversalApiContract (introduced in v1.0)
Open the WinUI 3 Gallery app and see the following Accessibility principles in action:
AutomationProperties is the host service class for several XAML attached properties. The purpose of these attached properties is to enable setting various per-instance values that are pertinent to how a UI element is reported to the Microsoft UI Automation accessibility framework. This is useful in cases where the class design of the UI element doesn't already forward other UI-related property values as part of its Microsoft UI Automation integration or peer implementation behavior, or where the value being forwarded is not the value you want to report to Microsoft UI Automation.
In order to support XAML processor access to the attached properties, and also to expose equivalent get and set operations to code, each XAML attached property has a pair of Get and Set accessor methods, which are also members of AutomationProperties. For example, the GetName and SetName methods support and provide the equivalent code-only support for reporting automation Name values to Microsoft UI Automation, instead of using the Name attached property to set it in XAML. Alternatively, you can use the dependency property system to get or set the value of the attached property, and this also reports the underlying value to Microsoft UI Automation. Call GetValue or SetValue, passing the arguments of the dependency property identifier to set, and a reference to the target object on which to get or set the value.
Of the various attached properties, probably the most important one is Name. This is because it is the Name property that is most frequently accessed and reported by assistive technology when users interact with an app in an accessibility scenario. The Name serves as the human-readable identifier for the UI element.
Various UI elements have peer forwarding that can provide a default Name value based on other element properties. For example, the peer forwarding for the Button class will forward the ToString evaluation of the Button content and use this string as the default Name. In order to override that default, or to otherwise provide a Name value for any UI element case where there is no Microsoft UI Automation Name available, set the Name attached property on that element in XAML. For more info on why a Microsoft UI Automation Name is important, see Basic accessibility information. For more info on how to test whether an element already has a peer-supplied Name that is useful, see Accessibility testing.
For localization reasons, you should avoid hard-coded string values for the Name in XAML. If you set x:Uid directive on the element, then you can use RESW resources to target the property and provide different values for localization. For attached properties, the resource identifier form requires full qualification of the attached property in XAML form, including its namespace and a using: prefix. For example, to target the AutomationProperties.Name attached property value on a resource that has x:Uid directive value of "sendButton", the name value of the data item in the RESW resources is
See Attached properties for a complete list (for more info about each attached property, see each property's Identifier field).
|Windows version||SDK version||Value added|
Gets or sets a string containing the accelerator key (also called shortcut key) combinations for the automation element.
Gets or sets the Microsoft UI Automation tree view mode for an element.
Gets or sets a string containing the access key character for the automation element.
Gets a list of annotation objects in a document, such as comment, header, footer, and so on.
Gets or sets the control type for Microsoft UI Automation.
Gets or sets the string that uniquely identifies the element to Microsoft UI Automation.
Gets a collection of automation elements that can be manipulated by the specified automation element.
Gets or sets the locale identifier for the automation element (for example, 0x0409 for "en-US" or English (United States)).
Gets an array of elements that provide more information about the automation element.
Gets an array of automation elements that suggests the reading order before the current automation element.
Gets an array of automation elements that suggests the reading order after the current automation element.
Gets or sets a localized string containing extended description text for an element.
Gets or sets the heading level for a UI Automation element.
Gets or sets a help text string associated with the automation element.
Gets or sets a value that indicates whether the data is valid for the form.
Gets or sets a value that indicates whether the automation element is a dialog window.
Gets or sets a value that indicates whether the automation element represents peripheral UI.
Gets or sets a value that indicates whether the element is required to be filled out on a form.
Gets or sets a description of the status of an item in an element.
Gets or sets a description of the type of the specified element.
Gets or sets the automation element that contains the text label for this element.
Gets or sets a Landmark Type Identifier associated with an element.
Gets or sets a 1-based integer that describes the location of an element inside hierarchical or broken hierarchical structures.
Gets or sets the live setting value for the specified element, which is supported by an automation element that represents a live region.
Gets or sets a localized text string that describes the type of control that the automation element represents.
Gets or sets a localized text string that describes the type of landmark that the automation element represents.
Gets or sets the UI Automation name of the element.
Gets or sets a 1-based integer that describes the ordinal location of the element within a set of elements that are considered to be siblings.
Gets or sets the number of elements in a set of elements that are considered to be siblings.