UI Automation Support for the Menu 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 Microsoft UI Automation support for the Menu control type. It describes the control's Microsoft UI Automation tree structure and provides the properties and control patterns for specific control scenarios.

A menu control allows hierarchal organization of elements associated with commands and event handlers. In a typical Microsoft Windows application, a menu bar contains several menu buttons (such as File, Edit, and Window), and each menu button displays a menu. A menu contains a collection of menu items (such as New, Open, and Close), which can be expanded to display additional menu items or to perform a specific action when clicked.

The following sections define the required UI Automation tree structure, properties, control patterns, and events for the Menu control type. The UI Automation requirements apply to all list 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 menu controls and describes what can be contained in each view. For more information on the UI Automation tree, see UI Automation Tree Overview.

Control ViewContent View

- MenuItem (1 or many)
Not applicable (unless the menu control is a context menu that is a parent of an object that is not a menu item)

- MenuItem (1 or many)

Menu controls always appear in the control view and the content view of the UI Automation tree. Menu control types should appear under the control that their information is referring to. UI Automation clients must listen for MenuOpenedEvent to ensure that they consistently obtain information conveyed by menu controls. Context menu controls are a special case. They appear as children of the Desktop.

The following table lists the UI Automation properties whose value or definition is especially relevant to the Menu control type. For more information on UI Automation properties, see UI Automation Properties for Clients.

UI Automation PropertyValueNotes
NamePropertyNot SupportedThe menu control does not require a Name property to be set.
LabeledByPropertyNullNo label is anticipated with a typical menu control.
ControlTypePropertyMenuThis value is the same for all UI frameworks.
IsContentElementPropertyFalseThe menu control is not included in the content view of the UI Automation tree.
IsControlElementPropertyTrueThe menu control is always included in the control view of the UI Automation tree.

There are no required control patterns for the Menu control type.

Menu controls must raise MenuOpenedEvent when they appear on the screen. The MenuOpenedEvent will include the text of the control. The MenuClosedEvent must be raised when a menu disappears from the screen.

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

UI Automation EventSupport/ValueNotes
BoundingRectangleProperty property-changed event.RequiredNone
IsOffscreenProperty property-changed event.RequiredNone
IsEnabledPropertyproperty-changed event.RequiredNone

UI Automation Control Patterns Overview
UI Automation Control Types Overview
UI Automation Overview