UI Automation Support for the Button Control Type


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.

Required UI Automation Tree Structure

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 View Content View

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

Required UI Automation Properties

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 Property Value Notes
AcceleratorKeyProperty See 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.
AutomationIdProperty See notes. The value of this property needs to be unique across all controls in an application.
BoundingRectangleProperty See notes. The outermost rectangle that contains the whole control.
ClickablePointProperty See 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.
ControlTypeProperty Button This value is the same for all UI frameworks.
HelpTextProperty See 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.
IsContentElementProperty True The Button control must always be content.
IsControlElementProperty True The Button control must always be a control.
IsKeyboardFocusableProperty See notes. If the control can receive keyboard focus, it must support this property.
LabeledByProperty Null Button controls are self-labeled by their contents.
LocalizedControlTypeProperty "button" Localized string corresponding to the Button control type.
NameProperty See 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.

Required UI Automation Control Patterns

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 Pattern Support Notes
IInvokeProvider See 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.
IToggleProvider See 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.
IExpandCollapseProvider See 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.

Required UI Automation Events

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 Event Support Notes
AutomationFocusChangedEvent Required None
BoundingRectangleProperty property-changed event. Required None
IsOffscreenProperty property-changed event. Required None
IsEnabledProperty property-changed event. Required None
NameProperty property-changed event. Required None
StructureChangedEvent Required None
InvokedEvent Depends If the control supports the Invoke control pattern, it must support this event.
ToggleStateProperty property-changed event. Depends If the control supports the Toggle control pattern, it must support this event.

See Also

UI Automation Control Types Overview
UI Automation Overview