I am wanting to receive keyboard input from a Popup control that acts as the root visual for a touch screen keyboard control. I’m wanting the control to support keyboard input as well as touch screen input. I hook up the events (PreviewKeyDown and KeyDown) and they are never fired.
Share
A
Popupis not focusable by default and even if it is focusable, you have to have something else focusable on the popup and then get it focused or give it the focus in order for it to receive keyboard event.In other words, if you want keyboard event from the
PopupuseFocusable="True"and put a focusable control like aTextBoxor aButtonor aListBoxand either let the user give it the focus by clicking on it or manually useFocus()from code. If you do all these things thenPreviewKeyDownshould fire for thePopup.Here is a little demonstration program with a toggle button that opens a
Popupand that shows a slider increasing whenever we get aPreviewKeyDownevent on aPopup: