Implementing the UI Automation Selection Control Pattern

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

The Selection control pattern is used to support controls that act as containers for a collection of selectable child items. The children of this element must implement ISelectionItemProvider. 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 ISelectionProvider
  • Related Topics

Implementation Guidelines and Conventions

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

  • Controls that implement ISelectionProvider allow either single or multiple child items to be selected. For example, list boxes, list views, and tree views support multiple selections, whereas combo boxes, sliders, and radio button groups support single selection.

  • Controls that have a minimum, maximum, and continuous range, such as the Volume slider control, should implement IRangeValueProvider instead of ISelectionProvider.

  • Single-selection controls that manage child controls that implement IRawElementProviderFragmentRoot, such as the Screen Resolution slider in the Display Properties dialog box, or the Color Picker selection control from Microsoft Word (see the following image), should implement ISelectionProvider; their children should implement both IRawElementProviderFragment and ISelectionItemProvider.

    Image showing an example of color swatch string mapping.

  • Menus do not support the Selection control pattern. If you are working with menu items that include both graphics and text (such as the Preview Pane items in the View menu in Microsoft Outlook) and need to convey state, you should implement IToggleProvider.

Required Members for ISelectionProvider

The following properties, methods, and events are required for implementing the ISelectionProvider interface.

Required members Member type Notes
ISelectionProvider::CanSelectMultiple Property None
ISelectionProvider::IsSelectionRequired Property None
ISelectionProvider::GetSelection Method None
InvalidatedEvent Event Raised (by calling UiaRaiseAutomationEvent with the UIA_Selection_InvalidatedEventId event ID) when a selection in a container has changed significantly.

The ISelectionProvider::IsSelectionRequired and ISelectionProvider::CanSelectMultiple properties can be dynamic. For example, the initial state of a control might not have any items selected by default, indicating that ISelectionProvider::IsSelectionRequired is false. However, after an item is selected, the control must always have at least one item selected. Similarly, in rare cases, a control might allow multiple items to be selected on initialization, but subsequently allow only single selections to be made.