AutomationEventArgs(AutomationEvent) 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 AutomationEventArgs 類別的新執行個體。
public:
AutomationEventArgs(System::Windows::Automation::AutomationEvent ^ eventId);
public AutomationEventArgs (System.Windows.Automation.AutomationEvent eventId);
new System.Windows.Automation.AutomationEventArgs : System.Windows.Automation.AutomationEvent -> System.Windows.Automation.AutomationEventArgs
Public Sub New (eventId As AutomationEvent)
參數
- eventId
- AutomationEvent
事件識別項。
範例
下列程式碼示範消費者介面自動化提供者如何建立 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