Share via


FocusManager.GetFocusedElement(DependencyObject) Yöntem

Tanım

Belirtilen odak kapsamında mantıksal odağı olan öğesini alır.

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

Parametreler

element
DependencyObject

Odak kapsamı olan bir öğe.

Döndürülenler

Mantıksal odak ile belirtilen odak kapsamındaki öğesi.

Özel durumlar

element, null değeridir.

Örnekler

Aşağıdaki örnek öğesini kullanarak SetFocusedElement mantıksal odak ile ayarlar ve öğesini kullanarak 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 bir odak kapsamı için mantıksal odağı olan öğedir. Odak kapsamı olan bir öğe olarak trueayarlanmıştırIsFocusScope. Bu nesnenin klavye odağı 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ış.

Odak kapsamı değilse element , bu yöntem döndürür null.

Belirtilen odak kapsamında mantıksal odağı olan öğesini belirtmek için kullanın SetFocusedElement.

Şunlara uygulanır