How to make WPF input control show virtual Keyboar

2019-01-17 03:15发布

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?


Updated:

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.


Updated 2:

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.

8条回答
来,给爷笑一个
2楼-- · 2019-01-17 04:13

I saw this done in a TechEd session, you need to first disable Inking support (DisableWPFTabletSupport) then you can create an InputPanelConfiguration (AutomationElement.FromHandle(new WindowsInteropHelper(this).Handle) and call EnableFocusTracking.

DisableWPFTabletSupport: http://msdn.microsoft.com/en-us/library/ee230087.aspx

EnableFocusTracking: http://msdn.microsoft.com/en-us/library/windows/desktop/jj126268(v=vs.85).aspx

查看更多
成全新的幸福
3楼-- · 2019-01-17 04:15
登录 后发表回答