Share via


FocusManager.GetFocusedElement Method (DependencyObject)

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

Gets the element with focus within the specified focus scope.

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

Syntax

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

Parameters

Return Value

Type: System.Object
The element in the specified focus scope that has current focus.

Exceptions

Exception Condition
ArgumentNullException

element cannot be null

Remarks

Generally there is only a single focus scope in a Silverlight application. However, modal dialogs and popups can introduce additional focus scopes, in which case using the overload that enables specifying the scoping object might be necessary.

In the current implementation, passing an element parameter value that is not of type Window will result in a returned value of null.

Version Information

Silverlight

Supported in: 5

Platforms

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