FocusManager.GetFocusedElement(DependencyObject) 메서드

정의

지정된 포커스 범위 내에서 논리적 포커스가 있는 요소를 가져옵니다.

public:
 static System::Windows::IInputElement ^ GetFocusedElement(System::Windows::DependencyObject ^ element);
public static System.Windows.IInputElement GetFocusedElement(System.Windows.DependencyObject element);
static member GetFocusedElement : System.Windows.DependencyObject -> System.Windows.IInputElement
Public Shared Function GetFocusedElement (element As DependencyObject) As IInputElement

매개 변수

element
DependencyObject

포커스 범위인 요소입니다.

반품

논리적 포커스가 있는 지정된 포커스 범위의 요소입니다.

예외

elementnull입니다.

예제

다음 예제에서는 요소를 사용하여 SetFocusedElement 논리적 포커스가 있는 요소를 설정하고 해당 요소를 사용하여 GetFocusedElement논리적 포커스가 있는 요소를 가져옵니다.

// Sets the focused element in focusScope1
// focusScope1 is a StackPanel.
FocusManager.SetFocusedElement(focusScope1, button2);

// Gets the focused element for focusScope 1
IInputElement focusedElement = FocusManager.GetFocusedElement(focusScope1);
' Sets the focused element in focusScope1
' focusScope1 is a StackPanel.
FocusManager.SetFocusedElement(focusScope1, button2)

' Gets the focused element for focusScope 1
Dim focusedElement As IInputElement = FocusManager.GetFocusedElement(focusScope1)

설명

특정 FocusedElement 포커스 범위에 대한 논리적 포커스가 있는 요소입니다. 포커스 범위인 요소가 .로 true설정되었습니다IsFocusScope. 이 개체에는 키보드 포커스가 있을 수도 있고 없을 수도 있습니다. 키보드 포커스는 키보드 입력을 수신하는 요소를 나타냅니다. 포커스, 키보드 포커스 및 논리적 포커스에 대한 자세한 내용은 입력 개요를 참조하세요.

element 포커스 범위가 아니면 이 메서드가 반환null됩니다.

를 사용하여 SetFocusedElement지정된 포커스 범위 내에서 논리적 포커스가 있는 요소를 지정합니다.

적용 대상