#1,070 – Event Sequence for Keyboard Focus Events

Events raised by user interface elements that are related to keyboard focus are:

  • PreviewLostKeyboardFocus  (tunneling)
  • PreviewGotKeyboardFocus  (tunneling)
  • LostKeyboardFocus  (bubbling)
  • GotKeyboardFocus  (bubbling)

When keyboard focus changes from one control to another, the events fired by the controls are in the order listed above.

Suppose that we have two TextBox controls in a StackPanel, which is contained within a Window.  If the first TextBox has keyboard focus and the user causes the second TextBox to receive focus, the sequence of events is as follows:

  • Window fires PreviewLostKeyboardFocus
  • StackPanel fires PreviewLostKeyboardFocus
  • TextBox #1 fires PreviewLostKeyboardFocus
  • Window fires PreviewGotKeyboardFocus
  • StackPanel fires PreviewGotKeyboardFocus
  • TextBox #2 fires PreviewGotKeyboardFocus
  • TextBox #1 fires LostKeyboardFocus
  • StackPanel fires LostKeyboardFocus
  • Window fires LostKeyboardFocus
  • TextBox #2 fires GotKeyboardFocus
  • StackPanel fires GotKeyboardFocus
  • Window fires GotKeyboardFocus

1070-001

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

One Response to #1,070 – Event Sequence for Keyboard Focus Events

  1. Pingback: Dew Drop – May 12, 2014 (#1774) | Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: