Focus
As mentioned previously, a UIElement receives keyboard input (and raises keyboard events) only if it has focus. For that to happen, it must first be eligible for focus, which means it must:
→ Be enabled (IsEnabled=true)
→ Be visible (Visibility=Visible)
→ Be hit-testable (HitTestVisible=true)
→ Be included in tab navigation (IsTabStop=true)
This list of requirements usually isn’t a big burden because the four properties listed are true by default.
Focus can be given only to Controls (indeed, some of the properties in this list are defined only by Control), so keyboard events can’t originate from any UIElement despite being defined by UIElement. They can be handled on non-Control UIElements containing Controls, however, thanks to event bubbling. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access