Raise Events from a UI Automation Provider
.NET Framework 4.5
Note
|
|---|
|
This documentation is intended for .NET Framework developers who want to use the managed UI Automation classes defined in the System.Windows.Automation namespace. For the latest information about UI Automation, see Windows Automation API: UI Automation. |
This topic contains example code that shows how to raise an event from a UI Automation provider.
In the following example, a UI Automation event is raised in the implementation of a custom button control. The implementation enables a UI Automation client application to simulate a button click.
To avoid unnecessary processing, the example checks ClientsAreListening to see whether events should be raised.
''' <summary> ''' Responds to a button click, regardless of whether it was caused by a ''' mouse or keyboard click or by InvokePattern.Invoke. ''' </summary> Private Sub OnCustomButtonClicked() '' TODO Perform program actions invoked by the control. '' Raise an event. If AutomationInteropProvider.ClientsAreListening Then Dim args As AutomationEventArgs = _ New AutomationEventArgs(InvokePatternIdentifiers.InvokedEvent) AutomationInteropProvider.RaiseAutomationEvent( _ InvokePatternIdentifiers.InvokedEvent, Me, args) End If End Sub
Note