C#

Keyboard Dismissing ComboBox

In the last few days I came across a design issue with the touch keyboard on Windows 8. The keyboard dismissal logic (documented here) defines a list of controls which do not cause the keyboard to dismiss when they get focused. The purpose is to prevent the keyboard from opening and closing all the time when the user fills out a form and is likely to switch between keyboard-editable controls such as TextBox and other controls like AppBar, Checkbox, RadioButtons the ComboBox and some more.

While that works fine with the other controls, ComboBox expands when interacted with and might get covered by the touch keyboard. And unfortunately you can’t change that behavior, or manually dismiss a deployed touch keyboard. (The user is in complete control over the keyboard.)

While on the MSDN forums it was suggested to alter the layout such that the ComboBox is less likely to collide with the touch keyboard, this was unacceptable in my case. (Screenshot below…)

Screenshot of my app, where I first met the problem
Screenshot of my app, where I first met the problem

I decided to go for a user control that encapsulates a real ComboBox, but intercepts the pointer, causing the keyboard to dismiss. This is done by setting IsHitTestVisible=false on the ComboBox and set it to true after the container (a Button control) was tapped (and caused the keyboard to dismiss). Because the ComboBox did not handle the tap, it need to be opened manually. You can of course control a ComboBox with the keyboard as well (arrow keys, space, enter, tab) and I had a few issues with that, but finally I got it right and now you can’t distinguish the KeyboardDismissingComboBox from a real one

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.