Breyta

Deila með


Keyboard.FocusedElement Property

Definition

Gets the element that has keyboard focus.

public:
 static property System::Windows::IInputElement ^ FocusedElement { System::Windows::IInputElement ^ get(); };
public static System.Windows.IInputElement FocusedElement { get; }
static member FocusedElement : System.Windows.IInputElement
Public Shared ReadOnly Property FocusedElement As IInputElement

Property Value

The focused element.

Examples

The following example gets the element with keyboard focus and casts it to a Control. If the element with keyboard focus is a Control, the background of the element is changed.

// Gets the element with keyboard focus.
UIElement elementWithFocus = Keyboard.FocusedElement as UIElement;
' Gets the element with keyboard focus.
Dim elementWithFocus As UIElement = TryCast(Keyboard.FocusedElement, UIElement)

Remarks

Keyboard focus refers to the object that is receiving keyboard input. The element with keyboard focus has IsKeyboardFocused set to true. There can be only one element with keyboard focus on the entire desktop. Logical focus refers to the object within a focus scope that has focus. For more information on focus, keyboard focus, and logical focus, see Input Overview and Focus Overview.

An element with keyboard focus also has logical focus for the focus scope the element belongs to. An element with logical focus may or may not have keyboard focus.

Applies to