Partilhar via


Visão Geral de Padrões de Controle de Automação de Interface de 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 overview introduces Microsoft UI Automation control patterns. Control patterns provide a way to categorize and expose a control's functionality independent of the control type or the appearance of the control.

UI Automation uses control patterns to represent common control behaviors. For example, you use the Invoke control pattern for controls that can be invoked (such as buttons) and the Scroll control pattern for controls that have scroll bars (such as list boxes, list views, or combo boxes). Because each control pattern represents a separate functionality, they can be combined to describe the full set of functionality supported by a particular control.

Observação

Agregam controles — criados com os controles filho que fornecem o user interface (UI) para a funcionalidade exposta pelo pai — deve implementar todos os padrões de controle normalmente associados com cada controle filho.In turn, those same control patterns are not required to be implemented by the child controls.

 

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

  • UI Automation Control Pattern Components
  • UI Automation Providers and Clients
  • Dynamic Control Patterns
  • Control Pattern Classes and Interfaces
  • Tópicos relacionados

 

UI Automation Control Pattern Components

Control patterns support the methods, properties, events, and relationships needed to define a discrete piece of functionality available in a control.

  • The relationship between a UI Automation element and its parent, children and siblings describes the element's structure within the UI Automation tree.

  • The methods allow UI Automation clients to manipulate the control.

  • The properties and events provide information about the control pattern's functionality as well as information about the state of the control.

Control patterns relate to UI as interfaces relate to Component Object Model (COM) objects. In COM, you can query an object to ask what interfaces it supports and then use those interfaces to access functionality. Em UI Automation, clientes de automação da interface do usuário pode pedir a um controle de qual controle padrões oferece suporte ele e, em seguida, interagir com o controle por meio de propriedades, métodos, eventos e estruturas expostas por padrões de controle com suporte. Por exemplo, para uma caixa de edição de várias linhas, a provedores de automação da interface do usuário implementar IScrollProvider. Quando um cliente sabe que um AutomationElement oferece suporte a ScrollPattern o padrão de controle, ele pode usar propriedades, métodos e eventos expostos por esse padrão de controle para manipular o controle, ou acessar informações sobre o controle.

UI Automation Providers and Clients

UI Automation providers implement control patterns to expose the appropriate behavior for a specific piece of functionality supported by the control.

UI Automation clients access methods and properties of UI Automation control pattern classes and use them to get information about the UI, or to manipulate the UI. These control pattern classes are found in the System.Windows.Automation namespace (for example, InvokePattern and SelectionPattern).

Os clientes usam AutomationElement métodos (como AutomationElement.GetCurrentPropertyValue ou AutomationElement.GetCachedPropertyValue) ou o common language runtime (CLR) acessadores para acessar o UI Automation Propriedades em um padrão. Cada classe de controle padrão tem um membro de campo (por exemplo, InvokePattern.Pattern ou SelectionPattern.Pattern) que identifica esse padrão de controle e pode ser passada como um parâmetro para GetCachedPattern ou GetCurrentPattern para recuperar esse padrão para um AutomationElement.

Dynamic Control Patterns

Some controls do not always support the same set of control patterns. Control patterns are considered supported when they are available to a UI Automation client. For example, a multiline edit box enables vertical scrolling only when it contains more lines of text than can be displayed in its viewable area. Scrolling is disabled when enough text is removed so that scrolling is no longer required. For this example, the ScrollPattern control pattern is dynamically supported depending on the current state of the control (how much text is in the edit box).

Control Pattern Classes and Interfaces

The following table describes the UI Automation control patterns. The table also lists the classes used by UI Automation clients to access the control patterns, as well as the interfaces used by UI Automation providers to implement them.

Control Pattern Class

Provider Interface

Description

DockPattern

IDockProvider

Used for controls that can be docked in a docking container. For example, toolbars or tool palettes.

ExpandCollapsePattern

IExpandCollapseProvider

Used for controls that can be expanded or collapsed. For example, menu items in an application such as the File menu.

GridPattern

IGridProvider

Used for controls that support grid functionality such as sizing and moving to a specified cell. For example, the large icon view in Windows Explorer or simple tables without headers in Microsoft Word.

GridItemPattern

IGridItemProvider

Used for controls that have cells within grids. The individual cells should support the GridItem pattern. Por exemplo, cada célula na Microsoft Windows Explorer exibição de detalhes.

InvokePattern

IInvokeProvider

Used for controls that can be invoked, such as a button.

MultipleViewPattern

IMultipleViewProvider

Used for controls that can switch between multiple representations of the same set of information, data, or children. For example, a list view control where data is available in thumbnail, tile, icon, list, or detail views.

RangeValuePattern

IRangeValueProvider

Used for controls that have a range of values that can be applied to the control. For example, a spinner control containing years might have a range of 1900 to 2010, while another spinner control presenting months would have a range of 1 to 12.

ScrollPattern

IScrollProvider

Used for controls that can scroll. For example, a control that has scroll bars that are active when there is more information than can be displayed in the viewable area of the control.

ScrollItemPattern

IScrollItemProvider

Used for controls that have individual items in a list that scrolls. For example, a list control that has individual items in the scroll list, such as a combo box control.

SelectionPattern

ISelectionProvider

Used for selection container controls. For example, list boxes and combo boxes.

SelectionItemPattern

ISelectionItemProvider

Used for individual items in selection container controls, such as list boxes and combo boxes.

TablePattern

ITableProvider

Used for controls that have a grid as well as header information. For example, Microsoft Excel worksheets.

TableItemPattern

ITableItemProvider

Used for items in a table.

TextPattern

ITextProvider

Used for edit controls and documents that expose textual information.

TogglePattern

IToggleProvider

Used for controls where the state can be toggled. For example, check boxes and checkable menu items.

TransformPattern

ITransformProvider

Used for controls that can be resized, moved, and rotated. Typical uses for the Transform control pattern are in designers, forms, graphical editors, and drawing applications.

ValuePattern

IValueProvider

Allows clients to get or set a value on controls that do not support a range of values. For example, a date time picker.

WindowPattern

IWindowProvider

Exposes information specific to windows, a fundamental concept to the Microsoft Windows operating system. Examples of controls that are windows are top-level application windows (Microsoft Word, Microsoft Windows Explorer, and so on), multiple-document interface (MDI) child windows, and dialogs.

Consulte também

Conceitos

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

Mapeamento de Padrão de Controles para Clientes de Automação de IU

UI Automation Overview

UI Automation Properties for Clients

Automação de Eventos de Interface de Usuário para Clientes.