简体   繁体   中英

How do I invoke or dismiss the touch keyboard in WPF using .NET 4.6.2?

Microsoft's release notes for .NET Framework 4.6.2 includes the following :

"Soft Keyboard support enables automatic invocation and dismissal of the touch keyboard in WPF applications without disabling WPF stylus/touch support on Windows 10. Prior to 4.6.2, WPF applications do not implicitly support the invocation or dismissal of the touch keyboard without disabling WPF stylus/touch support. This is due to a change in the way the touch keyboard tracks focus in applications starting in Windows 8."

The List of Changes likewise states:

"Enable automatic invocation and dismissal of the touch keyboard in WPF applications without disabling WPF stylus/touch support on Windows 10 [178044]"

But I cannot find any indication of HOW to do this, and I cannot find anything in the official API diff that seems to be this.

Can anyone help me find documentation of how to do this thing that I can now allegedly do?

My context is that I have an application that explicitly launches "OSK.exe" when needed. On touch devices with a built-in Windows on-screen keyboard, this results in TWO on-screen keyboards being shown. I want to disable the standard one and only launch "OSK.exe" explicitly.

Thanks!

I think this (especially the comments) should answer your question. The short story is: there is nothing specific to do, but it works only on Win10 anniversary edition.

To disable the soft keyboard, you can do what's indicate in the comments:

WPF on Windows 7 with touch: hide soft keyboard (and the popup icon that enables it)

or

https://blogs.msdn.microsoft.com/winuiautomation/2015/04/26/how-and-why-i-added-an-on-screen-keyboard-to-my-windows-store-app/

If in WPF on Windows 10 anniversary edition, you can override automation peer in TextBox:

protected override AutomationPeer OnCreateAutomationPeer()
 {
 return new FrameworkElementAutomationPeer(this);
 }

On Windows 7 it is enough to put

 InputMethod.IsInputMethodEnabled=”False”

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM