Automation.AddAutomationEventHandler 方法

定义

注册处理UI 自动化事件的方法。

C#
public static void AddAutomationEventHandler (System.Windows.Automation.AutomationEvent eventId, System.Windows.Automation.AutomationElement element, System.Windows.Automation.TreeScope scope, System.Windows.Automation.AutomationEventHandler eventHandler);

参数

eventId
AutomationEvent

该方法将处理的事件的标识符。

element
AutomationElement

要与事件处理程序关联的UI 自动化元素。

scope
TreeScope

要处理的事件的范围;即,它们是在元素本身上,还是在其上级和子代上。

eventHandler
AutomationEventHandler

发生指定事件时调用的方法。

注解

某些类(例如 GridPattern)公开标识特定于类的事件的字段。 此方法 AddAutomationEventHandler 提供了一种机制,可用于注册这些事件的处理程序。

eventHandler可以是方法的实例,也可以是对Visual Basic) 中方法 (AddressOf的引用。

适用于

产品 版本
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Windows Desktop 3.0, 3.1, 5, 6, 7

另请参阅