Compartilhar via


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

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 ISelectionProvider, including information about events and properties. Links to additional references are listed at the end of the topic.

The SelectionPattern 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 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 ISelectionProvider
  • Exceptions
  • Tópicos relacionados

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 box, list view, and tree view support multiple selections whereas combo box, slider, and radio button group support single selection.

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

  • Controles de seleção única para gerenciem os controles filho que implementam IRawElementProviderFragmentRoot, como o A resolução de tela controle deslizante no Propriedades de vídeo caixa de diálogo ou o Seletor de cores controle de seleção de Microsoft Word (ilustrado abaixo), deve implementar ISelectionProvider; seus filhos devem implementar ambos IRawElementProviderFragment e ISelectionItemProvider.

Example of Color Swatch String Mapping

Seletor de cores com amarelo realçado.

  • Menus do not support SelectionPattern. 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 the ISelectionProvider interface.

Required members

Type

Notes

CanSelectMultiple

Property

Should support property changed events using AddAutomationPropertyChangedEventHandler and RemoveAutomationPropertyChangedEventHandler.

IsSelectionRequired

Property

Should support property changed events using AddAutomationPropertyChangedEventHandler and RemoveAutomationPropertyChangedEventHandler.

GetSelection

Method

None

InvalidatedEvent

Event

Raised when a selection in a container has changed significantly and requires sending more addition and removal events than the InvalidateLimit constant permits.

The IsSelectionRequired and CanSelectMultiple properties can be dynamic. For example, the initial state of a control might not have any items selected by default, indicating that 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.

Exceptions

Providers must throw the following exceptions.

Exception Type

Condition

ElementNotEnabledException

If the control is not enabled.

InvalidOperationException

If the control is hidden.

Consulte também

Tarefas

Support Control Patterns in a UI Automation Provider

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

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

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