IRawElementProviderFragment.Navigate(NavigateDirection) Yöntem

Tanım

ağaç içinde belirtilen yönde UI Otomasyonu öğesini alır.

public:
 System::Windows::Automation::Provider::IRawElementProviderFragment ^ Navigate(System::Windows::Automation::Provider::NavigateDirection direction);
public System.Windows.Automation.Provider.IRawElementProviderFragment Navigate (System.Windows.Automation.Provider.NavigateDirection direction);
abstract member Navigate : System.Windows.Automation.Provider.NavigateDirection -> System.Windows.Automation.Provider.IRawElementProviderFragment
Public Function Navigate (direction As NavigateDirection) As IRawElementProviderFragment

Parametreler

direction
NavigateDirection

Gidilen yön.

Döndürülenler

IRawElementProviderFragment

Belirtilen yöndeki öğe veya null bu yönde öğe yoksa.

Örnekler

Aşağıdaki örnek kod, tek bir alt öğeye sahip bir parça kökü tarafından uygulamasını Navigate gösterir. Uygulayan öğe bir parça kökü olduğundan, üst öğeye veya eşdüzey öğelere gezintiyi etkinleştirmez.

IRawElementProviderFragment IRawElementProviderFragment.Navigate(NavigateDirection direction)
{
    if ((direction == NavigateDirection.FirstChild)
        || (direction == NavigateDirection.LastChild)) 
    {
        // Return the provider that is the sole child of this one.
        return (IRawElementProviderFragment)ChildControl;
    }
    else
    {
        return null;
    };
}
Function Navigate(ByVal direction As NavigateDirection) As IRawElementProviderFragment _
    Implements IRawElementProviderFragment.Navigate

    If direction = NavigateDirection.FirstChild _
        OrElse direction = NavigateDirection.LastChild Then
        ' Return the provider that is the sole child of this one.
        Return CType(ChildControl, IRawElementProviderFragment)
    Else
        Return Nothing
    End If

End Function 'IRawElementProviderFragment.Navigate

Aşağıdaki örnekte, bir liste kutusu içindeki tek bir öğeyi temsil eden bir parça tarafından kullanılabilecek bir uygulama gösterilmektedir. Bu durumda, öğesi üst ve eşdüzeylerine gezintiyi etkinleştirir, ancak herhangi bir alt öğeye değil.

/// <summary>
/// Navigate to adjacent elements in the automation tree.
/// </summary>
/// <param name="direction">Direction to navigate.</param>
/// <returns>The element in that direction, or null.</returns>
/// <remarks>
/// parentControl is the provider for the list box.
/// parentItems is the collection of list item providers.
/// </remarks>
public IRawElementProviderFragment Navigate(NavigateDirection direction)
{
    int myIndex = parentItems.IndexOf(this);
    if (direction == NavigateDirection.Parent)
    {
        return (IRawElementProviderFragment)parentControl;
    }
    else if (direction == NavigateDirection.NextSibling)
    {
        if (myIndex < parentItems.Count - 1)
        {
            return (IRawElementProviderFragment)parentItems[myIndex + 1];
        }
        else
        {
            return null;
        }
    }
    else if (direction == NavigateDirection.PreviousSibling)
    {
        if (myIndex > 0)
        {
            return (IRawElementProviderFragment)parentItems[myIndex - 1];
        }
        else
        {
            return null;
        }
    }
    else
    {
        return null;
    }
}
''' <summary>
''' Navigate to adjacent elements in the automation tree.
''' </summary>
''' <param name="direction">Direction to navigate.</param>
''' <returns>The element in that direction, or null.</returns>
''' <remarks>
''' parentControl is the provider for the list box.
''' parentItems is the collection of list item providers.
''' </remarks>
Public Function Navigate(ByVal direction As NavigateDirection) As IRawElementProviderFragment _
    Implements IRawElementProviderFragment.Navigate

    Dim myIndex As Integer = parentItems.IndexOf(Me)
    If direction = NavigateDirection.Parent Then
        Return DirectCast(parentControl, IRawElementProviderFragment)
    ElseIf direction = NavigateDirection.NextSibling Then
        If myIndex < parentItems.Count - 1 Then
            Return DirectCast(parentItems((myIndex + 1)), IRawElementProviderFragment)
        Else
            Return Nothing
        End If
    ElseIf direction = NavigateDirection.PreviousSibling Then
        If myIndex > 0 Then
            Return DirectCast(parentItems((myIndex - 1)), IRawElementProviderFragment)
        Else
            Return Nothing
        End If
    Else
        Return Nothing
    End If

End Function 'Navigate

Açıklamalar

UI Otomasyonu sunucusunun bu yöntemin uygulamaları, UI Otomasyonu öğe ağacının yapısını tanımlar.

Gezinti, üst öğeye yukarı, ilk ve son alt öğeye aşağı doğru ve sonraki ve önceki eşdüzeylere uygun olarak desteklenmelidir.

Her alt düğümün yalnızca bir üst öğesi vardır ve ile LastChildüst FirstChild düğümden ulaşılan eşdüzeyler zincirine yerleştirilmelidir.

Eşdüzeyler arasındaki ilişkiler her iki yönde de aynı olmalıdır: A B PreviousSiblingise, B A'nındır NextSibling. A FirstChild içinde LastChild ve içinde PreviousSiblingyokNextSibling.

Parça kökleri üst veya eşdüzeylerde gezinmeyi etkinleştirmez; parça kökleri arasındaki gezinti varsayılan pencere sağlayıcıları tarafından işlenir. Parçalardaki öğeler yalnızca o parçanın içindeki diğer öğelere gidmelidir.

Şunlara uygulanır

Ayrıca bkz.