Share via


Implementing the UI Automation ExpandCollapse Control Pattern

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 topic.
The ExpandCollapse 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 Control Pattern Mapping for UI Automation Clients.

This topic contains the following sections.

  • Implementation Guidelines and Conventions
  • Required Members for IExpandCollapseProvider
  • Related Topics

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 ExpandCollapse 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 ExpandCollapse control pattern.

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

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

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

  • IExpandCollapseProvider::Expand and IExpandCollapseProvider::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 IExpandCollapseProvider::Expand or IExpandCollapseProvider::Collapse is called.
    • Calling IExpandCollapseProvider::Expand on a TreeItem may display all descendants or only immediate children.
    • If calling IExpandCollapseProvider::Expand or IExpandCollapseProvider::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 IExpandCollapseProvider::ExpandCollapseState for each descendant and raise a visibility change event.
  • To guarantee navigation, it is desirable for an object to be in the Microsoft UI Automation tree (with appropriate visibility state) regardless of its parents IExpandCollapseProvider::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 the IExpandCollapseProvider interface.

Required members Member type Notes
IExpandCollapseProvider::ExpandCollapseState Property None
IExpandCollapseProvider::Expand Method None
IExpandCollapseProvider::Collapse Method None
IUIAutomationPropertyChangedEventHandler Event This control has no associated events; use this generic event handler.