Dela via


FocusManager.GetFocusedElement Method

Definition

Overloads

GetFocusedElement()

Retrieves the element in the UI that has focus.

GetFocusedElement(XamlRoot)

Retrieves the focused element within the Xaml island container.

GetFocusedElement()

Retrieves the element in the UI that has focus.

public:
 static Platform::Object ^ GetFocusedElement();
 static IInspectable GetFocusedElement();
public static object GetFocusedElement();
function getFocusedElement()
Public Shared Function GetFocusedElement () As Object

Returns

Object

Platform::Object

IInspectable

The object that has focus. Typically, this is a Control class.

Remarks

Warning

For WinUI 3 apps, this method always returns null as it relies on CoreWindow APIs not supported by WinUI 3.

Instead, use the FocusManager.GetFocusedElement(XamlRoot) overload, where XamlRoot can be retrieved any loaded UIElement through the XamlRoot property.

Applies to

GetFocusedElement(XamlRoot)

Retrieves the focused element within the Xaml island container.

public:
 static Platform::Object ^ GetFocusedElement(XamlRoot ^ xamlRoot);
/// [Windows.Foundation.Metadata.Overload("GetFocusedElement")]
 static IInspectable GetFocusedElement(XamlRoot const& xamlRoot);
[Windows.Foundation.Metadata.Overload("GetFocusedElement")]
public static object GetFocusedElement(XamlRoot xamlRoot);
function getFocusedElement(xamlRoot)
Public Shared Function GetFocusedElement (xamlRoot As XamlRoot) As Object

Parameters

xamlRoot
XamlRoot

Returns

Object

Platform::Object

IInspectable

The object that has focus. Typically, this is a Control class.

Attributes

Windows requirements

Device family
Windows 10, version 1903 (introduced in 10.0.18362.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v8.0)

See also

Applies to