AutomationElement.Current Właściwość

Definicja

Pobiera bieżące wartości właściwości elementu 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

Wartość właściwości

AutomationElement.AutomationElementInformation

Struktura zawierająca bieżące wartości właściwości.

Wyjątki

Interfejs użytkownika dla obiektu AutomationElement już nie istnieje.

Przykłady

W poniższym przykładzie pokazano, jak Current właściwość jest używana do pobierania nazwy elementu wybranego na liście.

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

Uwagi

Metody dostępu dla właściwości automatyzacja interfejsu użytkownika są reprezentowane jako właściwości struktury zwracanej przez Currentelement . Nie trzeba pobierać struktury; Możesz uzyskać bezpośredni dostęp do jego członków, jak w poniższym przykładzie. Aby uzyskać szczegółowe informacje o dostępnych właściwościach i ich użyciu, zobacz AutomationElement.AutomationElementInformation.

Aby uzyskać buforowana wartość właściwości automatyzacja interfejsu użytkownika dla tego elementu, użyj Cached właściwości .

Dotyczy

Zobacz też