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
事件标识符。
示例
以下代码演示UI 自动化提供程序如何创建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