Bagikan melalui


AutomationElement.Current Properti

Definisi

Mendapatkan nilai properti saat ini dari 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

Nilai Properti

Struktur yang berisi nilai properti saat ini.

Pengecualian

Contoh

Contoh berikut menunjukkan bagaimana Current properti digunakan untuk mengambil nama item yang telah dipilih dalam daftar.

/// <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

Keterangan

Aksesor untuk properti Automation UI diwakili sebagai properti struktur yang dikembalikan oleh Current. Anda tidak perlu mengambil struktur; Anda dapat mengakses anggotanya secara langsung, seperti pada contoh di bawah ini. Untuk informasi spesifik tentang properti yang tersedia dan penggunaannya, lihat AutomationElement.AutomationElementInformation.

Untuk mendapatkan nilai cache properti Automation UI pada elemen ini, gunakan Cached properti .

Berlaku untuk

Lihat juga