FocusManager.GetFocusedElement(DependencyObject) Metodo

Definizione

Ottiene l'elemento con stato attivo logico all'interno dell'ambito dello stato attivo specificato.

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

Parametri

element
DependencyObject

Elemento che è un ambito dello stato attivo.

Valori restituiti

Elemento nell'ambito dello stato attivo specificato con stato attivo logico.

Eccezioni

element è null.

Esempio

Nell'esempio seguente l'elemento con stato attivo logico viene impostato usando SetFocusedElement e ottiene l'elemento con lo stato attivo logico usando .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)

Commenti

FocusedElement è l'elemento con stato attivo logico per un ambito specifico dello stato attivo. Un elemento che è un ambito dello stato attivo è IsFocusScope impostato su true. Questo oggetto può avere o meno lo stato attivo della tastiera. Lo stato attivo della tastiera fa riferimento all'elemento che riceve l'input da tastiera. Per altre informazioni sullo stato attivo, lo stato attivo della tastiera e lo stato attivo logico, vedere Panoramica dell'input.

Se element non è un ambito dello stato attivo, questo metodo restituirà null.

Usare SetFocusedElement, per specificare l'elemento con stato attivo logico all'interno di un ambito di stato attivo specificato.

Si applica a