FocusManager.SetFocusedElement(DependencyObject, IInputElement) Yöntem

Tanım

Mantıksal odağı belirtilen öğeye ayarlar.

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)

Parametreler

element
DependencyObject

Belirtilen öğesinin FocusedElementolarak ayarlandığı odak kapsamı.

value
IInputElement

Mantıksal odak vermek için öğe.

Örnekler

Aşağıdaki örnek öğesini kullanarak mantıksal odakla ayarlar ve öğesini kullanarak SetFocusedElement mantıksal odak GetFocusedElementile alır.

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

Açıklamalar

FocusedElement, belirli odak kapsamı için mantıksal odağı olan öğedir. Bu nesne klavye odağına sahip olabilir veya olmayabilir. Klavye odağı, klavye girişi alan öğeyi ifade eder. Odak, klavye odağı ve mantıksal odak hakkında daha fazla bilgi için bkz. Girişe Genel Bakış.

Öğenin içinde olduğu odak kapsamının bir atası olan bir odak kapsamı belirtmek mümkündür. Örneğin, bir StackPanel odak kapsamı ve üst öğesi Window bir odak kapsamıysa, öğesinin alt TextBox öğesi StackPanel çağrılırken Windowodak kapsamı olarak öğesini belirtebilirSetFocusedElement. TextBox daha sonra FocusedElement hem odak kapsamı hem de Window odak kapsamı için olurStackPanel.

SetFocusedElement belirtilen öğeye belirtilen odak kapsamında mantıksal odak verir ve öğe klavye odağını vermeyi dener.

Şunlara uygulanır