IRawElementProviderFragmentRoot.GetFocus 메서드

정의

이 조각에서 입력 포커스가 있는 요소를 검색합니다.

public:
 System::Windows::Automation::Provider::IRawElementProviderFragment ^ GetFocus();
public System.Windows.Automation.Provider.IRawElementProviderFragment GetFocus ();
abstract member GetFocus : unit -> System.Windows.Automation.Provider.IRawElementProviderFragment
Public Function GetFocus () As IRawElementProviderFragment

반환

IRawElementProviderFragment

이 조각에서 입력 포커스가 있는 요소에 대한 공급자이고(있는 경우), 그렇지 않으면 null 참조(Visual Basic의 경우 Nothing)입니다.

예제

다음 코드 예제에서는 목록 상자에 대 한이 메서드의 가능한 구현을 보여 주세요. 목록에서 현재 선택한 항목을 반환합니다.

/// <summary>
/// Returns the child element that is selected when the list gets focus.
/// </summary>
/// <returns>The selected item.</returns>
/// <remarks>
/// SelectedIndex is a class property that maintains the index of the currently
/// selected item in the myItems collection.</remarks>
IRawElementProviderFragment IRawElementProviderFragmentRoot.GetFocus()
{
    if (SelectedIndex >= 0)
    {
        return (IRawElementProviderFragment)myItems[SelectedIndex];
    }
    else
    {
        return null;
    }
}
''' <summary>
''' Returns the child element that is selected when the list gets focus.
''' </summary>
''' <returns>The selected item.</returns>
''' <remarks>
''' SelectedIndex is a class property that maintains the index of the currently
''' selected item in the myItems collection.</remarks>
Function GetFocus() As IRawElementProviderFragment _
    Implements IRawElementProviderFragmentRoot.GetFocus

    If SelectedIndex >= 0 Then
        Return DirectCast(myItems(SelectedIndex), IRawElementProviderFragment)
    Else
        Return Nothing
    End If
End Function 'IRawElementProviderFragmentRoot.GetFocus

설명

포커스가 이 조각에 의해 호스팅되는 다른 프레임워크의 요소에 있는 경우 메서드는 해당 조각을 호스트하는 요소를 반환합니다.

적용 대상

추가 정보