问题
I am currently working in a UWP application. I have a situation where I need to open the taptip keyboard. The device needs to be in desktop mode and the keyboard should open on a button click. Is there any way I can achieve this functionality?
- I know it works fine in tablet mode when a text box gets focus but I need to get it done in desktop mode and on a button click.
- I know it can be done from a console application using System.Diagnostics.Process but I need a way around for uwp app.
回答1:
The user can enable the tip to show when a text box gets focus in a desktop app by setting the "Show the touch keyboard when not in tablet mode and there's no keyboard attached". Apps should generally defer to the user's preferences on this rather than trying to override this themselves.
That said, you can show and hide the InputPane via the InputPane.TryShow and InputPane.TryHide methods.
You'll do essentially the same from a desktop app via the IInputPaneInterop and IInputPane2 interfaces. Launching tabtip.exe explicitly is limited and not generally recommended.
来源:https://stackoverflow.com/questions/47886654/how-to-open-tabtip-keyboard-in-a-uwp-app-in-desktop-mode-on-button-click