#306 – Keyboard Focus
May 24, 2011 7 Comments
In WPF, as in other Windows applications, a control or user interface element has focus if it can receive keyboard input. Specifically, we say that the control has keyboard focus.
By default, when a WPF application start up, no control has focus. You can give a control focus by pressing the TAB key–which cycles through all of the controls that are able to receive focus. You can also give a control focus by clicking on the control.
Not all controls are able to receive focus. In general, only controls that can accept user input can get focus.
Most controls will give some visual indication that the control currently has keyboard focus. Many controls will display a dashed line around the control to indicate that it has focus. The TextBox will display a light blue border to show that it has focus and also contain an editing carat.