FocusManager.SetFocusedElement(DependencyObject, IInputElement) 메서드

정의

지정된 요소에 대한 논리적 포커스를 설정합니다.

public:
 static void SetFocusedElement(System::Windows::DependencyObject ^ element, System::Windows::IInputElement ^ value);
public static void SetFocusedElement(System.Windows.DependencyObject element, System.Windows.IInputElement value);
static member SetFocusedElement : System.Windows.DependencyObject * System.Windows.IInputElement -> unit
Public Shared Sub SetFocusedElement (element As DependencyObject, value As IInputElement)

매개 변수

element
DependencyObject

지정된 요소를 .로 만들 포커스 범위입니다 FocusedElement.

value
IInputElement

논리적 포커스를 부여할 요소입니다.

예제

다음 예제에서는 요소를 사용하여 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 포커스 범위에 대한 논리적 포커스가 있는 요소입니다. 이 개체에는 키보드 포커스가 있을 수도 있고 없을 수도 있습니다. 키보드 포커스는 키보드 입력을 수신하는 요소를 나타냅니다. 포커스, 키보드 포커스 및 논리적 포커스에 대한 자세한 내용은 입력 개요를 참조하세요.

요소가 있는 포커스 범위의 상위 항목인 포커스 범위를 지정할 수 있습니다. 예를 들어 포커스 StackPanel 범위이고 해당 부모가 Window 포커스 범위인 TextBox 경우 자 StackPanel 식은 호출SetFocusedElement할 때 포커스 범위로 지정할 Window 수 있습니다. TextBox 그런 다음 FocusedElement 포커스 범위와 포커스 범위 둘 다 WindowStackPanel 대한 것입니다.

SetFocusedElement 는 지정된 포커스 범위에서 지정된 요소 논리 포커스를 제공하고 요소 키보드 포커스를 제공하려고 시도합니다.

적용 대상