For our WPF application, when it runs on touch screen(Surface Pro .etc), the TextBox
/PasswordBox
control cannot show virtual keyboard when they get focused.
Any good way to implement this feature in WPF?
what we want to achieve finally is something like that:
If user run app on PC, we don't care about this feature, which means whether user has physical keyboard, we do nothing just like normal WPF application running on PC.
If user run on Surface Pro, when he clicks the TextBox
, the built-in virtual keyboard can show up, and which should be user-friendly, such as the keyboard would never cover up the input element.
So, WPF cannot easily set some property to implement this feature? In my opinion, this feature should be built-in WPF, I don't understand why I cannot find an easy way to achieve.
Try this,
First check for a physical keyboard presence:
KeyboardCapabilities keyboardCapabilities = new Windows.Devices.Input.KeyboardCapabilities();
return keyboardCapabilities.KeyboardPresent != 0 ? true : false;
If you do not find a physical keyboard, use the in-built virtual keyboard of windows:
Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.System) + Path.DirectorySeparatorChar + "osk.exe");