UI 自动化对 Window 控件类型的支持

注意注意

本文档的目标读者是欲使用 System.Windows.Automation 命名空间中定义的托管 UI Automation类的 .NET Framework 开发人员。有关 UI Automation的最新信息,请参见 Windows Automation API: UI Automation(Windows 自动化 API:UI 自动化)。

本主题介绍 UI Automation对 Window 控件类型的支持。 在 UI Automation中,控件类型是一组条件,控件必须满足这些条件才能使用 ControlTypeProperty 属性。 这些条件包括 UI Automation树结构的特定准则、UI Automation属性值和控件模式。

Window 控件由窗口框架组成,通常包含子对象,例如标题栏、客户端和其他对象。

以下几节中的 UI Automation要求适用于用来实现 Window 控件类型的所有控件,无论控件是 Windows Presentation Foundation (WPF)、Win32 还是 Windows Forms。

本主题包括下列各节。

  • 必需的 UI 自动化树结构
  • 必需的 UI 自动化属性
  • 必需的 UI 自动化控件模式
  • 必需的 UI 自动化事件
  • 相关主题

必需的 UI 自动化树结构

下表描述了与 Window 控件有关的 UI Automation树的控件视图和内容视图,以及每个视图中可包含的内容。 有关 UI Automation树的更多信息,请参见 UI 自动化树概述

控件视图

内容视图

Window

Window

必需的 UI 自动化属性

下表列出了值或定义与 Window 控件密切相关的 UI Automation属性。 有关 UI Automation 属性的更多信息,请参见 客户端的 UI 自动化属性

UI Automation属性

注释

AutomationIdProperty

请参见“说明”。

此属性的值在应用程序的所有控件中都必须保持唯一。

BoundingRectangleProperty

请参见“说明”。

包含整个控件的最外面的矩形。

ClickablePointProperty

请参见“说明”。

Window 控件必须有一个使该窗口能够被选定或取消选中的可单击点。

ControlTypeProperty

Window

此值对于所有的 UI 框架均相同。

IsContentElementProperty

True

Window 控件必须始终是内容。

IsControlElementProperty

True

Window 控件必须始终是控件。

IsKeyboardFocusableProperty

请参见“说明”。

如果该控件可以接收键盘焦点,则它必须支持此属性。

LabeledByProperty

null

Window 控件没有静态窗口标签。

LocalizedControlTypeProperty

"window"

与 Window 控件类型相对应的本地化字符串。

NameProperty

请参见“说明”。

Window 控件始终包含一个关于某个内容的主要 Window 元素,用户希望将该内容作为最能表示该项语义的标识符来关联。

必需的 UI 自动化控件模式

下表列出了必须由 Window 控件支持的 UI Automation控件模式。 有关控件模式的更多信息,请参见 UI 自动化控件模式概述

控件模式

支持

注释

IDockProvider

条件运算

如果窗口能够停靠,则必须受支持。

ITransformProvider

必需

使窗口能够进行移动、大小调整或在屏幕上旋转。

IWindowProvider

必需

支持针对窗口的特定操作。

必需的 UI 自动化事件

下表列出了所有 Window 控件必须支持的 UI Automation事件。 有关事件的更多信息,请参见 UI 自动化事件概述

UI Automation事件

支持

注释

AsyncContentLoadedEvent

必需

AutomationFocusChangedEvent

必需

BoundingRectangleProperty property-changed 事件。

必需

IsEnabledProperty property-changed 事件。

必需

IsOffscreenProperty property-changed 事件。

必需

LayoutInvalidatedEvent

必需

NameProperty property-changed 事件。

必需

StructureChangedEvent

必需

HorizontallyScrollableProperty property-changed 事件。

视情况而定

HorizontalScrollPercentProperty property-changed 事件。

视情况而定

HorizontalViewSizeProperty property-changed 事件。

视情况而定

VerticalScrollPercentProperty property-changed 事件。

视情况而定

VerticallyScrollableProperty property-changed 事件。

视情况而定

VerticalViewSizeProperty property-changed 事件。

视情况而定

WindowClosedEvent

必需

WindowOpenedEvent

必需

WindowVisualStateProperty property-changed 事件。

视情况而定

请参见

参考

Window

概念

UI 自动化控件类型概述

UI 自动化概述