Automation.AddAutomationEventHandler Method

Definition

Registers a method that handles UI Automation events.

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

Parameters

eventId
AutomationEvent

The identifier for the event the method will handle.

element
AutomationElement

The UI Automation element to associate with the event handler.

scope
TreeScope

The scope of events to be handled; that is, whether they are on the element itself, or on its ancestors and descendants.

eventHandler
AutomationEventHandler

The method to call when the specified event occurs.

Remarks

Some classes, such as GridPattern, expose fields identifying events that are specific to the class. The AddAutomationEventHandler method provides a mechanism that enables you to register handlers for these events.

eventHandler can be an instance of the method, or a reference to the method (AddressOf in Visual Basic).

Applies to

產品 版本
.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, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also