TreeWalker.GetParent 메서드

정의

지정된 AutomationElement의 부모 요소를 검색합니다.

오버로드

GetParent(AutomationElement)

지정된 AutomationElement의 부모 요소를 검색합니다.

GetParent(AutomationElement, CacheRequest)

지정된 AutomationElement의 부모 요소를 검색하고 속성 및 패턴을 캐시합니다.

설명

바탕 화면에 표시되는 UI(사용자 인터페이스) 요소가 변경됨에 따라 트리의 구조 AutomationElement 가 변경됩니다. 반환 된 요소가 부모 요소를 부모로 다음 번에 반환 됩니다는 보장 되지 않습니다.

GetParent(AutomationElement)

지정된 AutomationElement의 부모 요소를 검색합니다.

public:
 System::Windows::Automation::AutomationElement ^ GetParent(System::Windows::Automation::AutomationElement ^ element);
public System.Windows.Automation.AutomationElement GetParent (System.Windows.Automation.AutomationElement element);
member this.GetParent : System.Windows.Automation.AutomationElement -> System.Windows.Automation.AutomationElement
Public Function GetParent (element As AutomationElement) As AutomationElement

매개 변수

element
AutomationElement

부모를 반환할 요소입니다.

반환

AutomationElement

부모 요소이거나, 지정된 요소가 트리의 루트 요소이거나 부모 요소가 현재 뷰에 표시되지 않는 경우 null 참조(Visual Basic의 경우 Nothing)입니다.

예제

다음 예제에서는 GetParent 지정된 된 요소를 포함 하는 창 요소를 찾는 데 사용 되 고 있습니다.

/// <summary>
/// Retrieves the top-level window that contains the specified UI Automation element.
/// </summary>
/// <param name="element">The contained element.</param>
/// <returns>The containing top-level window element.</returns>
private AutomationElement GetTopLevelWindow(AutomationElement element)
{
    TreeWalker walker = TreeWalker.ControlViewWalker;
    AutomationElement elementParent;
    AutomationElement node = element;
    if (node == elementRoot) return node;
    do
    {
        elementParent = walker.GetParent(node);
        if (elementParent == AutomationElement.RootElement) break;
        node = elementParent;
    }
    while (true);
    return node;
}
    ''' <summary>
    ''' Retrieves the top-level window that contains the specified UI Automation element.
    ''' </summary>
    ''' <param name="element">The contained element.</param>
    ''' <returns>The containing top-level window element.</returns>
    Private Function GetTopLevelWindow(ByVal element As AutomationElement) As AutomationElement 
        Dim walker As TreeWalker = TreeWalker.ControlViewWalker
        Dim elementParent As AutomationElement
        Dim node As AutomationElement = element
        If node = elementRoot Then
            Return node
        End If
        Do
            elementParent = walker.GetParent(node)
            If elementParent = AutomationElement.RootElement Then
                Exit Do
            End If
            node = elementParent
        Loop While True
        Return node
    
    End Function 'GetTopLevelWindow
End Class

추가 정보

적용 대상

GetParent(AutomationElement, CacheRequest)

지정된 AutomationElement의 부모 요소를 검색하고 속성 및 패턴을 캐시합니다.

public:
 System::Windows::Automation::AutomationElement ^ GetParent(System::Windows::Automation::AutomationElement ^ element, System::Windows::Automation::CacheRequest ^ request);
public System.Windows.Automation.AutomationElement GetParent (System.Windows.Automation.AutomationElement element, System.Windows.Automation.CacheRequest request);
member this.GetParent : System.Windows.Automation.AutomationElement * System.Windows.Automation.CacheRequest -> System.Windows.Automation.AutomationElement
Public Function GetParent (element As AutomationElement, request As CacheRequest) As AutomationElement

매개 변수

element
AutomationElement

부모를 반환할 요소입니다.

request
CacheRequest

반환된 AutomationElement에서 캐시할 멤버를 지정하는 캐시 요청 개체입니다.

반환

AutomationElement

부모 요소이거나, 지정된 요소가 트리의 루트 요소이거나 부모 요소가 이 뷰에 표시되지 않는 경우 null 참조(Visual Basic의 경우 Nothing)입니다.

설명

바탕 화면에 표시되는 UI(사용자 인터페이스) 요소가 변경됨에 따라 트리의 구조 AutomationElement 가 변경됩니다. 반환 된 요소가 부모 요소를 부모로 다음 번에 반환 됩니다는 보장 되지 않습니다.

추가 정보

적용 대상