Share via


AutomationElement.Current Proprietà

Definizione

Ottiene la proprietà corrente dell'oggetto AutomationElement.

public:
 property System::Windows::Automation::AutomationElement::AutomationElementInformation Current { System::Windows::Automation::AutomationElement::AutomationElementInformation get(); };
public System.Windows.Automation.AutomationElement.AutomationElementInformation Current { get; }
member this.Current : System.Windows.Automation.AutomationElement.AutomationElementInformation
Public ReadOnly Property Current As AutomationElement.AutomationElementInformation

Valore della proprietà

AutomationElement.AutomationElementInformation

Struttura che contiene i valori di proprietà correnti.

Eccezioni

L'interfaccia utente per AutomationElement non esiste più.

Esempio

Nell'esempio seguente viene illustrato come viene usata la Current proprietà per recuperare il nome di un elemento selezionato in un elenco.

/// <summary>
/// Handles ElementSelected events by showing a message.
/// </summary>
/// <param name="src">Object that raised the event; in this case, a list item.</param>
/// <param name="e">Event arguments.</param>
private void OnSelect(object src, AutomationEventArgs e)
{
    // Get the name of the item, which is equivalent to its text.
    AutomationElement element = src as AutomationElement;
    if (element != null)
    {
        Console.WriteLine(element.Current.Name + " was selected.");
    }
}
''' <summary>
''' Handles ElementSelected events by showing a message.
''' </summary>
''' <param name="src">Object that raised the event; in this case, a list item.</param>
''' <param name="e">Event arguments.</param>
Private Sub OnSelect(ByVal src As Object, ByVal e As AutomationEventArgs)
    ' Get the name of the item, which is equivalent to its text.
    Dim element As AutomationElement = DirectCast(src, AutomationElement)
    If (element IsNot Nothing) Then
        Console.WriteLine(element.Current.Name + " was selected.")
    End If

End Sub

Commenti

Le funzioni di accesso per Automazione interfaccia utente proprietà sono rappresentate come proprietà della struttura restituita da Current. Non è necessario recuperare la struttura; è possibile accedere direttamente ai membri, come nell'esempio seguente. Per informazioni specifiche sulle proprietà disponibili e sull'uso, vedere AutomationElement.AutomationElementInformation.

Per ottenere il valore memorizzato nella cache di proprietà Automazione interfaccia utente in questo elemento, usare la Cached proprietà .

Si applica a

Vedi anche