Поделиться через


FocusManager.GetFocusedElement Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

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

Syntax

'Declaration
Public Shared Function GetFocusedElement As Object
public static Object GetFocusedElement()

Return Value

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

Remarks

GetFocusedElement can return nulla null reference (Nothing in Visual Basic) 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.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

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

Platforms

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