Compartilhar via


Implementando o padrão de controle de automação de interface do usuário ExpandCollapse

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.

This topic introduces guidelines and conventions for implementing IExpandCollapseProvider, including information about properties, methods, and events. Links to additional references are listed at the end of the overview.

The ExpandCollapsePattern control pattern is used to support controls that visually expand to display more content and collapse to hide content. For examples of controls that implement this control pattern, see Mapeamento de Padrão de Controles para Clientes de Automação de IU.

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

  • Implementation Guidelines and Conventions
  • Required Members for IExpandCollapseProvider
  • Exceptions
  • Tópicos relacionados

Implementation Guidelines and Conventions

When implementing the ExpandCollapse control pattern, note the following guidelines and conventions:

  • Aggregate controls—built with child objects that provide the UI with expand/collapse functionality—must support the ExpandCollapsePattern control pattern whereas their child elements do not. For example, a combo box control is built with a combination of list box, button, and edit controls, but it is only the parent combo box that must support the ExpandCollapsePattern.

    Observação

    An exception is the menu control, which is an aggregate of individual MenuItem objects.The MenuItem objects can support the ExpandCollapsePattern control pattern, but the parent Menu control cannot.A similar exception applies to the Tree and Tree Item controls.

  • When the ExpandCollapseState of a control is set to LeafNode, any ExpandCollapsePattern functionality is currently inactive for the control and the only information that can be obtained using this control pattern is the ExpandCollapseState. If any child objects are subsequently added, the ExpandCollapseState changes and ExpandCollapsePattern functionality is activated.

  • ExpandCollapseState refers to the visibility of immediate child objects only; it does not refer to the visibility of all descendant objects.

  • Expand and Collapse functionality is control-specific. The following are examples of this behavior.

    • The Office Personal Menu can be a tri-state MenuItem (Expanded, Collapsed and PartiallyExpanded) where the control specifies the state to adopt when an Expand or Collapse is called.

    • Calling Expand on a TreeItem may display all descendants or only immediate children.

    • If calling Expand or Collapse on a control maintains the state of its descendants, a visibility change event should be sent, not a state change event If the parent control does not maintain the state of its descendants when collapsed, the control may destroy all the descendants that are no longer visible and raise a destroyed event; or it may change the ExpandCollapseState for each descendant and raise a visibility change event.

  • To guarantee navigation, it is desirable for an object to be in the UI Automation tree (with appropriate visibility state) regardless of its parents ExpandCollapseState. If descendants are generated on demand, they may only appear in the UI Automation tree after being displayed for the first time or only while they are visible.

Required Members for IExpandCollapseProvider

The following properties and methods are required for implementing IExpandCollapseProvider.

Required members

Member type

Notes

ExpandCollapseState

Property

None

Expand

Method

None

Collapse

Method

None

AutomationPropertyChangedEventHandler

Event

This control has no associated events; use this generic delegate.

Exceptions

Providers must throw the following exceptions.

Exception type

Condition

InvalidOperationException

Either Expand or Collapse is called when the ExpandCollapseState = LeafNode.

Consulte também

Tarefas

Support Control Patterns in a UI Automation Provider

Navigate Among UI Automation Elements with TreeWalker

Use Caching in UI Automation

Conceitos

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

Padrões de Controle para Clientes de Automação de IU

Visão geral da árvore de automação de interface do usuário