Called before the GotFocus event occurs.
The data for the event.
OnGotFocus represents a prewired event handler for the UIElement.GotFocus event. Practical controls that derive from Control can override the OnGotFocus method and use this to provide control-specific handling and behavior for that input event. The most common scenario is to use the event handler to mark the event as Handled in the event data. The control code has first chance to handle this event, before any event handlers that are wired on a control instance are invoked. When the event data is marked Handled, then other handlers like those on the control instance won't be called. Also, the event won't bubble. For more info, see the "On* event handler overrides" section in Control.
As it's implemented directly on Control, OnGotFocus has an empty implementation. But each ancestor in a control's hierarchy may have provided an implementation. You won't be able to see this implementation because it's internal native code. In some cases a control will already have existing On* overrides that mark the event Handled. Once you've provided an initial On* override for a control, then any controls that you further derive from your own control class would also inherit the On* overrides you define. Any instances you use have that behavior too.
Note App code can still handle events that may have been marked Handled by a control's On* method logic, but they need to use the handledEventsToo parameter for the UIElement.AddHandler method. For more info, see UIElement.AddHandler or Events and routed events overview.
Minimum supported client
Minimum supported server
|Windows Server 2012|
- Events and routed events overview
- Gestures, manipulations, and interactions
- Quickstart: Pointers