GettingFocusEventArgs Class

Definition

Provides data for the FocusManager.GettingFocus and UIElement.GettingFocus events.

Equivalent WinUI class: Microsoft.UI.Xaml.Input.GettingFocusEventArgs.

public ref class GettingFocusEventArgs sealed : RoutedEventArgs
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 262144)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class GettingFocusEventArgs final : RoutedEventArgs
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 262144)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class GettingFocusEventArgs : RoutedEventArgs
Public NotInheritable Class GettingFocusEventArgs
Inherits RoutedEventArgs
Inheritance
GettingFocusEventArgs
Attributes

Windows 10 requirements

Device family
Windows 10 Creators Update (introduced in 10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v4.0)

Remarks

Only a single UI element at a time can have focus.

A control can get focus when another control loses focus, the application view changes, the user switches applications, or the user interacts with the system such that the application is no longer in the foreground.

Version history

Windows version SDK version Value added
1803 17134 TryCancel
1803 17134 TrySetNewFocusedElement
1809 17763 CorrelationId

Properties

Cancel

Gets or sets whether focus navigation should be canceled.

Equivalent WinUI property: Microsoft.UI.Xaml.Input.GettingFocusEventArgs.Cancel.

CorrelationId

Gets the unique ID generated when a focus movement event is initiated.

Equivalent WinUI property: Microsoft.UI.Xaml.Input.GettingFocusEventArgs.CorrelationId.

Direction

Gets the direction that focus moved from element to element within the app UI.

Equivalent WinUI property: Microsoft.UI.Xaml.Input.GettingFocusEventArgs.Direction.

FocusState

Gets the input mode through which an element obtained focus.

Equivalent WinUI property: Microsoft.UI.Xaml.Input.GettingFocusEventArgs.FocusState.

Handled

Gets or sets a value that marks the routed event as handled. A true value for Handled prevents most handlers along the event route from handling the same event again.

Equivalent WinUI property: Microsoft.UI.Xaml.Input.GettingFocusEventArgs.Handled.

InputDevice

Gets the input device type from which input events are received.

Equivalent WinUI property: Microsoft.UI.Xaml.Input.GettingFocusEventArgs.InputDevice.

NewFocusedElement

Gets the most recent focused object.

Equivalent WinUI property: Microsoft.UI.Xaml.Input.GettingFocusEventArgs.NewFocusedElement.

OldFocusedElement

Gets the last focused object.

Equivalent WinUI property: Microsoft.UI.Xaml.Input.GettingFocusEventArgs.OldFocusedElement.

OriginalSource

Gets a reference to the object that raised the event. This is often a template part of a control rather than an element that was declared in your app UI.

Equivalent WinUI property: Microsoft.UI.Xaml.RoutedEventArgs.OriginalSource.

(Inherited from RoutedEventArgs)

Methods

TryCancel()

Attempts to cancel the ongoing focus action.

Equivalent WinUI method: Microsoft.UI.Xaml.Input.GettingFocusEventArgs.TryCancel.

TrySetNewFocusedElement(DependencyObject)

Attempts to redirect focus to the specified element instead of the original targeted element.

Equivalent WinUI method: Microsoft.UI.Xaml.Input.GettingFocusEventArgs.TrySetNewFocusedElement.

Applies to

See also