Muokkaa

Jaa


UI Automation Support for the Menu Control Type

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.

Required UI Automation Tree Structure

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

- 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.

Required UI Automation Properties

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 Property Value Notes
NameProperty Not Supported The menu control does not require a Name property to be set.
LabeledByProperty Null No label is anticipated with a typical menu control.
ControlTypeProperty Menu This value is the same for all UI frameworks.
IsContentElementProperty False The menu control is not included in the content view of the UI Automation tree.
IsControlElementProperty True The menu control is always included in the control view of the UI Automation tree.

Required UI Automation Control Patterns

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

Required UI Automation Events

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 Event Support/Value Notes
MenuOpenedEvent Required None
MenuClosedEvent Required None
BoundingRectangleProperty property-changed event. Required None
IsOffscreenProperty property-changed event. Required None
IsEnabledProperty property-changed event. Required None
AutomationFocusChangedEvent Required None
StructureChangedEvent Required None

See also