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.
This solution is very simple: http://code.msdn.microsoft.com/windowsapps/Enabling-Windows-8-Touch-7fb4e6de
The steps are detailed in the link above, here is the short version:
InkInputHelper.DisableWPFTabletSupport();
fromMainWindow
constructor or similarusing System.Windows.Interop;
Add to MainWindow_Loaded or similar:
To convert inputpanelconfiguration.idl to DLL
On Windows 8.1: c:\Program Files (x86)\Windows Kits\8.1\Include\um\inputpanelconfiguration.idl
To build a DLL from the IDL use the following steps:
midl /tbld {filename}
TLBIMP.exe InputpanelConfiguration.tlb /publickey:{pathToKey} /delaysign
InkInputHelper class:
This should work. Again, much better info and a downloadable sample in the link. I only copy pasted the basics for archiving purposes.
The easiest option when not requiring SecureString output is to use TextBox and use something like Wingdings as font.
I created a library to automate everything concerning TabTip integration in WPF app.
You can get it on nuget, and after that all you need is a simple config in your apps startup logic:
You can bind TabTip automation logic to any UIElement. Virtual Keyboard will open when any element of specified type will get focus, and it will close when element will lose focus. Not only that, but TabTipAutomation will move UIElement (or Window) into view, so that TabTip will not block focused element.
For more info refer to the project site.
I've published a sample on how to trigger the touch keyboard in WPF applications when a user clicks into a Textbox, its here:
http://code.msdn.microsoft.com/Enabling-Windows-8-Touch-7fb4e6de
It has been something I've been working on for many months, i'm glad to finally contribute this example to our community. Please let me know if there are any questions, suggestions, problems, etc in the sample Q&A pane
use that class to determine if there is a physical keyboard, or a similar way that might better suit your needs.
i used this class to open and close the keyboard wherever i wanted.
keep in mind the following: i added a copy of both osk.exe AND tabtip.exe. adding this in my program solved an issue where either tabtip or osk wouldnt work on 32/64 bits.
osk is the keyboard, tabtip is the docked version of it. keyboardexecuter is a program i made which is used as a fallback method.
note* i can currently not test this on a touch screen device. you have to try that on your own.
for this to all work correctly i used this code in my mainwindow:
i included the comments because it might be usefull to someone if there is an error.
the inputpanel configuration:
i hope this might help future visitors of this question.
Try this,
First check for a physical keyboard presence:
If you do not find a physical keyboard, use the in-built virtual keyboard of windows:
Got help from here: link 1 link 2