语言

Automation.AddAutomationEventHandler 方法

定义

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

public:
 static void AddAutomationEventHandler(System::Windows::Automation::AutomationEvent ^ eventId, System::Windows::Automation::AutomationElement ^ element, System::Windows::Automation::TreeScope scope, System::Windows::Automation::AutomationEventHandler ^ eventHandler);
public static void AddAutomationEventHandler(System.Windows.Automation.AutomationEvent eventId, System.Windows.Automation.AutomationElement element, System.Windows.Automation.TreeScope scope, System.Windows.Automation.AutomationEventHandler eventHandler);
static member AddAutomationEventHandler : System.Windows.Automation.AutomationEvent * System.Windows.Automation.AutomationElement * System.Windows.Automation.TreeScope * System.Windows.Automation.AutomationEventHandler -> unit
Public Shared Sub AddAutomationEventHandler (eventId As AutomationEvent, element As AutomationElement, scope As TreeScope, eventHandler As AutomationEventHandler)

参数

eventId
AutomationEvent

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

element
AutomationElement

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

scope
TreeScope

要处理的事件的范围;也就是说,无论是在元素本身上,还是在元素的祖先和后代上。

eventHandler
AutomationEventHandler

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

注解

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

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

适用于

另请参阅