Partilhar via


AutomationEventArgs.EventId Propriedade

Definição

Obtém o identificador de evento.

public:
 property System::Windows::Automation::AutomationEvent ^ EventId { System::Windows::Automation::AutomationEvent ^ get(); };
public System.Windows.Automation.AutomationEvent EventId { get; }
member this.EventId : System.Windows.Automation.AutomationEvent
Public ReadOnly Property EventId As AutomationEvent

Valor da propriedade

AutomationEvent

O identificador de evento.

Exemplos

No exemplo a seguir, o manipulador de eventos verifica o EventId evento e manipula o evento de acordo.

/// <summary>
/// AutomationEventHandler delegate.
/// </summary>
/// <param name="src">Object that raised the event.</param>
/// <param name="e">Event arguments.</param>
private void OnUIAutomationEvent(object src, AutomationEventArgs e)
{
    // Make sure the element still exists. Elements such as tooltips
    // can disappear before the event is processed.
    AutomationElement sourceElement;
    try
    {
        sourceElement = src as AutomationElement;
    }
    catch (ElementNotAvailableException)
    {
        return;
    }
    if (e.EventId == InvokePattern.InvokedEvent)
    {
        // TODO Add handling code.
    }
    else
    {
        // TODO Handle any other events that have been subscribed to.
    }
}
''' <summary>
''' AutomationEventHandler delegate.
''' </summary>
''' <param name="src">Object that raised the event.</param>
''' <param name="e">Event arguments.</param>
Private Sub OnUIAutomationEvent(ByVal src As Object, ByVal e As AutomationEventArgs)
    ' Make sure the element still exists. Elements such as tooltips can disappear
    ' before the event is processed.
    Dim sourceElement As AutomationElement
    Try
        sourceElement = DirectCast(src, AutomationElement)
    Catch ex As ElementNotAvailableException
        Exit Sub
    End Try
    If e.EventId Is InvokePattern.InvokedEvent Then
        ' TODO Add handling code.
    Else
    End If
    ' TODO Handle any other events that have been subscribed to.
    Console.WriteLine("Event: " & e.EventId.ProgrammaticName)
End Sub

Comentários

Se um cliente tiver adicionado manipuladores de eventos para mais de um evento usando a mesma AutomationEventHandler instância, EventId poderá ser usado para identificar o evento que o delegado deve processar.

Aplica-se a