FocusManager.GetFocusedElement Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
GetFocusedElement() |
Retrieves the element in the UI that has focus. |
GetFocusedElement(XamlRoot) |
Retrieves the focused element within the Xaml island container. |
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
The object that has focus. Typically, this is a Control class.
Remarks
Waarschuwing
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
WinRT Build 26100 en andere versies
Product | Versies |
---|---|
WinRT | Build 10240, Build 10586, Build 14383, Build 15063, Build 16299, Build 17134, Build 17763, Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100 |
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
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
- GetFocusedElement()
- Keyboard interactions
- Focus navigation for keyboard, gamepad, remote control, and accessibility tools
- Programmatic focus navigation
Applies to
WinRT Build 26100 en andere versies
Product | Versies |
---|---|
WinRT | Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100 |