Share via


AutomationInteropProvider.RaiseAutomationEvent 方法

定义

引发模式事件或自定义事件。

public:
 static void RaiseAutomationEvent(System::Windows::Automation::AutomationEvent ^ eventId, System::Windows::Automation::Provider::IRawElementProviderSimple ^ provider, System::Windows::Automation::AutomationEventArgs ^ e);
public static void RaiseAutomationEvent (System.Windows.Automation.AutomationEvent eventId, System.Windows.Automation.Provider.IRawElementProviderSimple provider, System.Windows.Automation.AutomationEventArgs e);
static member RaiseAutomationEvent : System.Windows.Automation.AutomationEvent * System.Windows.Automation.Provider.IRawElementProviderSimple * System.Windows.Automation.AutomationEventArgs -> unit
Public Shared Sub RaiseAutomationEvent (eventId As AutomationEvent, provider As IRawElementProviderSimple, e As AutomationEventArgs)

参数

eventId
AutomationEvent

事件标识符。

provider
IRawElementProviderSimple

与该事件关联的元素。

e
AutomationEventArgs

有关事件的信息。

示例

/// <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);
    }
}
''' <summary>
''' Raises an event when a control is invoked.
''' </summary>
''' <param name="provider">The UI Automation provider for the control.</param>
Private Sub RaiseInvokeEvent(ByVal provider As IRawElementProviderSimple)
    If AutomationInteropProvider.ClientsAreListening Then
        Dim args As New AutomationEventArgs(InvokePatternIdentifiers.InvokedEvent)
        AutomationInteropProvider.RaiseAutomationEvent(InvokePatternIdentifiers.InvokedEvent, provider, args)
    End If

End Sub

注解

模式事件不应仅由模式实现引发。 例如, InvokedEvent 每当通过 Invoke 鼠标或键盘输入调用控件时,都应引发 。 通过这种方式,可以通知客户端有关系统事件的信息。

适用于

另请参阅