IRawElementProviderFragment.Navigate(NavigateDirection) 메서드

정의

트리 내에서 지정된 방향으로 UI 자동화 요소를 검색합니다.

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

매개 변수

direction
NavigateDirection

탐색할 방향입니다.

반환

IRawElementProviderFragment

지정된 방향의 요소이거나 null 해당 방향에 요소가 없는 경우입니다.

예제

다음 예제 코드는 단일 자식 요소가 있는 조각 루트에 Navigate 의한 구현을 보여 냅니다. 구현 요소는 조각 루트이므로 부모 요소 또는 형제 요소에 대한 탐색을 사용하도록 설정하지 않습니다.

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

다음 예제에서는 목록 상자 내의 단일 항목을 나타내는 조각에 의한 구현을 보여 줍니다. 이 경우 요소는 부모 및 형제를 탐색할 수 있지만 자식은 탐색할 수 없습니다.

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

설명

이 메서드의 UI 자동화 서버 구현은 UI 자동화 요소 트리의 구조를 정의합니다.

탐색은 부모 위로, 첫 번째 및 마지막 자식까지 아래쪽으로, 그리고 해당하는 경우 다음 형제 및 이전 형제로 횡적으로 지원되어야 합니다.

각 자식 노드에는 부모 노드가 하나뿐이며 부모 노드에서 FirstChild LastChild도달한 형제의 체인에 배치되어야 합니다.

형제 간의 관계는 양방향으로 동일해야 합니다. A가 B인 경우 B PreviousSibling는 A NextSibling입니다. A FirstChild 에는 no PreviousSibling, 및 a가 LastChild 없습니다 NextSibling.

조각 루트는 부모 또는 형제를 탐색할 수 없습니다. 조각 루트 간의 탐색은 기본 창 공급자에 의해 처리됩니다. 조각의 요소는 해당 조각 내의 다른 요소로만 이동해야 합니다.

적용 대상

추가 정보