AutomationInteropProvider.RaiseAutomationEvent Method (AutomationEvent, IRawElementProviderSimple, AutomationEventArgs)

 

Raises a pattern event or a custom event.

Namespace:   System.Windows.Automation.Provider
Assembly:  UIAutomationProvider (in UIAutomationProvider.dll)

public static void RaiseAutomationEvent(
	AutomationEvent eventId,
	IRawElementProviderSimple provider,
	AutomationEventArgs e
)

Parameters

eventId
Type: System.Windows.Automation.AutomationEvent

The event identifier.

provider
Type: System.Windows.Automation.Provider.IRawElementProviderSimple

The element associated with the event.

e
Type: System.Windows.Automation.AutomationEventArgs

Information about the event.

Pattern events should not be raised just by a pattern implementation. For example, an InvokedEvent should be raised whenever the control is invoked, either through Invoke or through mouse or keyboard input. In this way, clients can be informed about system events.

/// <summary>
/// Raises an event when a control is invoked.
/// </summary>
/// <param name="provider">The UI Automation provider for the control.</param>
private void RaiseInvokeEvent(IRawElementProviderSimple provider)
{
    if (AutomationInteropProvider.ClientsAreListening)
    {
        AutomationEventArgs args = 
            new AutomationEventArgs(InvokePatternIdentifiers.InvokedEvent);
        AutomationInteropProvider.RaiseAutomationEvent(InvokePatternIdentifiers.InvokedEvent, 
            provider, args);
    }
}

.NET Framework
Available since 3.0
Return to top
Show: