UI Automation Support for the Button Control Type

 
System_CAPS_ICON_note.jpg Note

This documentation is intended for .NET Framework developers who want to use the managed UI Automation classes defined in the System.Windows.Automation namespace. For the latest information about UI Automation, see Windows Automation API: UI Automation.

This topic provides information about UI Automation support for the Button control type. In UI Automation, a control type is a set of conditions that a control must meet in order to use the ControlTypeProperty property. The conditions include specific guidelines for UI Automation tree structure, UI Automation property values, control patterns, and UI Automation events.

A button is an object that a user interacts with to perform an action such as the OK and Cancel buttons on a dialog box. The button control is a simple control to expose because it maps to a single command that the user wishes to complete.

The following sections define the required UI Automation tree structure, properties, control patterns, and events for the Button control type. The UI Automation requirements apply to all button controls, whether Windows Presentation Foundation (WPF), Win32, or Windows Forms.

The following table depicts the control view and the content view of the UI Automation tree that pertains to button controls and describes what can be contained in each view. For more information about the UI Automation tree, see UI Automation Tree Overview.

Control ViewContent View
Button

- Image (0 or more)
- Text (0 or more)
Button

The following table lists the UI Automation properties whose value or definition is especially relevant to the controls that implement the Button control type (such as button controls). For more information about UI Automation properties, see UI Automation Properties for Clients.

UI Automation PropertyValueNotes
AcceleratorKeyPropertySee notes.The Button control typically must support an accelerator key to enable an end user to perform the action it represents quickly from the keyboard.
AutomationIdPropertySee notes.The value of this property needs to be unique across all controls in an application.
BoundingRectanglePropertySee notes.The outermost rectangle that contains the whole control.
ClickablePointPropertySee notes.Supported if there is a bounding rectangle. If not every point within the bounding rectangle is clickable, and you perform specialized hit testing, then override and provide a clickable point.
ControlTypePropertyButtonThis value is the same for all UI frameworks.
HelpTextPropertySee notes.The Help Text can indicate what the end result of activating the button will be. This is typically the same type of information presented through a ToolTip.
IsContentElementPropertyTrueThe Button control must always be content.
IsControlElementPropertyTrueThe Button control must always be a control.
IsKeyboardFocusablePropertySee notes.If the control can receive keyboard focus, it must support this property.
LabeledByPropertyNullButton controls are self-labeled by their contents.
LocalizedControlTypeProperty"button"Localized string corresponding to the Button control type.
NamePropertySee notes.The name of the button control is the text that is used to label it. Whenever an image is used to label a button, alternate text must be supplied for the button's Name property.

The following table lists the UI Automation control patterns required to be supported by all button controls. For more information on control patterns, see UI Automation Control Patterns Overview.

Control PatternSupportNotes
IInvokeProviderSee notes.All buttons should support the Invoke control pattern or the Toggle control pattern. Invoke is supported when the button performs a command at the request of the user. This command maps to a single operation such as Cut, Copy, Paste, or Delete.
IToggleProviderSee notes.All buttons should support the Invoke control pattern or the Toggle control pattern. Toggle is supported if the button can be cycled through a series of up to three states. Typically this is seen as an on/off switch for specific features.
IExpandCollapseProviderSee notes.When a button is hosted as a child of a split button, the child button can support the ExpandCollapse pattern instead of the Invoke or Toggle pattern. The ExpandCollapse pattern can be used for opening or closing a menu or other sub-structure associated with the button element.

The following table lists the UI Automation events required to be supported by all button controls. For more information on events, see UI Automation Events Overview.

UI Automation EventSupportNotes
AutomationFocusChangedEventRequiredNone
BoundingRectangleProperty property-changed event.RequiredNone
IsOffscreenProperty property-changed event.RequiredNone
IsEnabledProperty property-changed event.RequiredNone
NameProperty property-changed event.RequiredNone
StructureChangedEventRequiredNone
InvokedEventDependsIf the control supports the Invoke control pattern, it must support this event.
ToggleStateProperty property-changed event.DependsIf the control supports the Toggle control pattern, it must support this event.

Button
UI Automation Control Types Overview
UI Automation Overview

Show: