#1,068 – Most Controls Can Get Keyboard Focus

In WPF, controls that a user interacts with are typically able to get keyboard focus.  (Focusable property is true).  This includes controls that supported text-based input, like the TextBox.  But it also includes controls that the user typically interacts with using the mouse, rather than the keyboard.

Controls that cannot get keyboard focus are ones like the Label that the user does not interact with.

For example, a user will typically use only the mouse when interacting with a Button or a CheckBox, but both of these controls can get keyboard focus.  This is because the user can also interact with these controls using the keyboard.  (E.g. Enter key to “click” a Button, or Spacebar to toggle a CheckBox).

The example below uses code to detect which control has focus.  Note that as we tab through the controls, the TextBox controls get focus, as well as the Button and the CheckBox.

1068-001

1068-002

1068-003

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,068 – Most Controls Can Get Keyboard Focus

  1. Pingback: Dew Drop – May 8, 2014 (#1772) | 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: