FocusManager.GetFocusedElement Method


Queries the Silverlight focus system to determine which object has focus.

Namespace:  System.Windows.Input
Assembly:  System.Windows (in System.Windows.dll)

public static Object GetFocusedElement()

Return Value

Type: System.Object
The object that currently has focus. Typically, this is a Control class.

GetFocusedElement can return null in certain cases. This might happen if there are no true Control class instances anywhere in the Silverlight UI, or if the hosting browser does not have focus.

Silverlight focus has the characteristic that while the focus-reporting events GotFocus and LostFocus are raised asynchronously, the focus returned by GetFocusedElement is determined synchronously. This design attempts to loosen constraints on runtime adjustments to element trees that could result from having to wait for the focus to be determined and moved.


Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions