Compartilhar via


Suporte de Automação de Interface de Usuário para o Tipo de Controle MenuItem

Observação

Esta documentação destina.Os desenvolvedores do NET Framework que desejam usar o gerenciado UI Automation classes definidas na System.Windows.Automation namespace.As informações mais recentes sobre UI Automation, consulte API de automação do Windows: Automação da interface do usuário.

Este tópico fornece informações sobre Microsoft UI Automation suporte para MenuItem o tipo de controle. Ele descreve o controle Microsoft UI Automation estrutura em árvore e fornece as propriedades e padrões de controle que são necessários para o tipo de controle de MenuItem.

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 items (such as File, Edit, and Window), and each menu item 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 perform a specific action when clicked. Um item de menu pode ser hospedado em um menu, barra de menus ou barra de ferramentas.

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

Este tópico contém as seguintes seções.

  • Required UI Automation Tree Structure
  • Required UI Automation Properties
  • Required UI Automation Control Patterns
  • UI Automation Events for Menu Item
  • Required UI Automation Events
  • Legacy Issues
  • Tópicos relacionados

Required UI Automation Tree Structure

A tabela a seguir ilustra o modo de exibição do controle e o a exibir conteúdo da UI Automation árvore que diz respeito aos controles de item de menu e descreve o que pode estar contido em cada exibição. For more information on the UI Automation tree, see Visão geral da árvore de automação de interface do usuário.

Control View

Content View

MenuItem "Help"

  • Menu (menu de sub do item de menu Ajuda)

    • MenuItem "Help Topics"

    • MenuItem "About Notepad"

MenuItem "Help"

  • MenuItem "Help Topics"

  • MenuItem "About Notepad"

The control view of the menu item control has the UI Automation tree structure shown above. Observe que o Help o item de menu é inlcluded para melhor ilustrar a estrutura de um menu típico para a hierarquia do submenu.

For the content view, Menu is absent from the UI Automation tree because it does not convey meaningful information to the end user.

Required UI Automation Properties

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

Property

Value

Description

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.

IsKeyboardFocusableProperty

See notes.

If the control can receive keyboard focus, it must support this property.

NameProperty

See notes.

The menu item control is included in the content view of the UI Automation tree and is self labeled with a name.

LabeledByProperty

Null

No label.

ControlTypeProperty

MenuItem

This value is the same for all UI frameworks.

LocalizedControlTypeProperty

"menu item"

Localized string corresponding to the MenuItem control type.

IsContentElementProperty

True

The menu item control is never included in the content view of the UI Automation tree.

IsControlElementProperty

True

The menu item control must always be included in the control view of the UI Automation tree.

Required UI Automation Control Patterns

The following table lists the UI Automation control patterns required to be supported by menu item controls. For more information on control patterns, see Visão Geral de Padrões de Controle de Automação de Interface de Usuário.

Propriedade do controle padrão

Support

Notes

IExpandCollapseProvider

Depends

If the control can be expanded or collapsed, implement IExpandCollapseProvider.

IInvokeProvider

Depends

If the control executes a single action or command, implement IInvokeProvider.

IToggleProvider

Depends

If the control represents an option that can be turned on or off, implement IToggleProvider.

ISelectionItemProvider

Depends

If the control is used to select from a list of options among menu items, implement ISelectionItemProvider.

UI Automation Events for Menu Item

The following table lists the Microsoft UI Automation events associated with the menu item control.

Event

Support

Explanation

InvokedEvent

Depends

Must be raised if control supports Invoke control pattern.

ToggleStateProperty property-changed event.

Depends

Must be raised if control supports Toggle control pattern.

ExpandCollapseStateProperty property-changed event.

Depends

Must be raised if control supports Expand Collapse control pattern.

ElementSelectedEvent

Depends

Nenhum.

Required UI Automation Events

The following table lists the UI Automation events required to be supported by all menu item controls. For more information on events, see Visão geral sobre eventos de automação de interface do usuário.

UI Automation Event

Support/Value

Notes

InvokedEvent

Depends

None

ElementAddedToSelectionEvent

Depends

None

ElementRemovedFromSelectionEvent

Depends

None

ElementSelectedEvent

Depends

None

BoundingRectangleProperty property-changed event.

Required

None

IsOffscreenProperty property-changed event.

Required

None

IsEnabledProperty property-changed event.

Required

None

ExpandCollapseStateProperty property-changed event.

Depends

None

ToggleStateProperty property-changed event.

Depends

None

AutomationFocusChangedEvent

Required

None

StructureChangedEvent

Required

None

Legacy Issues

Toggle Pattern will only be supported when the Win32 menu item is checked and can be programmatically determined necessary to support Toggle Pattern. Because the Win32 menu item does not expose whether it has the ability to be checked, Invoke Pattern will be supported when the menu item is not checked. An exception will be made to always support Invoke Pattern even for menu items that should only support Toggle Pattern. This is so clients do not become confused that an element that was supporting Invoke Pattern (when menu item was unchecked) no longer supports the pattern once it becomes checked.

Consulte também

Referência

MenuItem

Conceitos

Visão Geral de Padrões de Controle de Automação de Interface de Usuário

Visão Geral dos Tipos de Controle de Automação de Interface do Usuário

UI Automation Overview