Click here to Skip to main content
15,867,704 members
Articles / Desktop Programming / WPF
Tip/Trick

Virtual Keyboard (TabTip) Integration in WPF on Win 8.1 and Win 10

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
23 Aug 2016CPOL 62.4K   5   29
Virtual Keyboard (TabTip) integration in WPF on Win 8.1 and Win 10

Introduction

I open-sourced my project to automate everything concerning TabTip integration in WPF app.

Simple to use

The easiest way to install the WPFTabTip is using the Package Manager Console in Visual Studio:

C#
PM> Install-Package WPFTabTip

One line of code in your startup logic, and you are good to go!

C#
TabTipAutomation.BindTo<TextBox>();

You can bind TabTip automation logic to any UIElement. Virtual Keyboard will open when any such element 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.

Hardware Keyboard Detection

By default, TabTip automation will occur only if no hardware keyboard is detected.

You can change that behavior by setting TabTipAutomation.IgnoreHardwareKeyboard to any of the following values:

C#
public enum HardwareKeyboardIgnoreOptions
    {
        /// <summary>
        /// Do not ignore any keyboard.
        /// </summary>
        DoNotIgnore,

        /// <summary>
        /// Ignore keyboard, if there is only one, and it's description 
        /// can be found in ListOfHardwareKeyboardsToIgnoreIfSingleInstance.
        /// </summary>
        IgnoreIfSingleInstanceOnList,

        /// <summary>
        /// Ignore keyboard, if there is only one.
        /// </summary>
        IgnoreIfSingleInstance,

        /// <summary>
        /// Ignore all keyboards
        /// </summary>
        IgnoreAll
    }

If you want to ignore specific keyboard, you should set TabTipAutomation.IgnoreHardwareKeyboard to IgnoreIfSingleInstanceOnList, and add keyboard description to TabTipAutomation.ListOfHardwareKeyboardsToIgnoreIfSingleInstance.

To get description of keyboards connected to machine, you can use the following code:

C#
new ManagementObjectSearcher(new SelectQuery("Win32_Keyboard")).Get()
                .Cast<ManagementBaseObject>()
                .SelectMany(keyboard =>
                    keyboard.Properties
                        .Cast<PropertyData>()
                        .Where(k => k.Name == "Description")
                        .Select(k => k.Value as string))
                .ToList();

Change Keyboard Layout

To specify keyboard layout to be used with certain element, you can set InputScope property in XAML to one of the following:

  • Default
  • Url
  • EmailSmtpAddress
  • Number

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader
Russian Federation Russian Federation
Max Fedotov is currently working in Moscow, Russia.
His set of skills include C#, XAML, Silverlight, WPF as well as Delphi and InterSystems Caché.

Comments and Discussions

 
QuestionRemove Emoji button Pin
themoscy3-Apr-20 1:10
themoscy3-Apr-20 1:10 
Hi Max, really good work on the WPF keyboard!

I was wondering, is there a way to hide some of the buttons? Specifically I would like to prevent the users from entering Emojis by either hiding or disabling the button!
Suggestion5* but some issues Pin
Nasenbaaer13-Feb-19 22:35
Nasenbaaer13-Feb-19 22:35 
QuestionNon admin user Pin
Member 259687123-Mar-17 7:43
Member 259687123-Mar-17 7:43 
AnswerRe: Non admin user Pin
Max Fedotov24-Mar-17 5:48
Max Fedotov24-Mar-17 5:48 
QuestionUse InputScope="Number" with DataGridTextColumn? Pin
rburrough110-Oct-16 1:22
rburrough110-Oct-16 1:22 
AnswerRe: Use InputScope="Number" with DataGridTextColumn? Pin
Max Fedotov10-Oct-16 1:28
Max Fedotov10-Oct-16 1:28 
GeneralRe: Use InputScope="Number" with DataGridTextColumn? Pin
rburrough112-Oct-16 10:46
rburrough112-Oct-16 10:46 
GeneralRe: Use InputScope="Number" with DataGridTextColumn? Pin
Max Fedotov12-Oct-16 20:03
Max Fedotov12-Oct-16 20:03 
GeneralRe: Use InputScope="Number" with DataGridTextColumn? Pin
rburrough126-Oct-16 10:58
rburrough126-Oct-16 10:58 
GeneralRe: Use InputScope="Number" with DataGridTextColumn? Pin
Max Fedotov26-Oct-16 20:01
Max Fedotov26-Oct-16 20:01 
PraiseThanks Pin
rburrough110-Oct-16 1:13
rburrough110-Oct-16 1:13 
GeneralRe: Thanks Pin
Max Fedotov10-Oct-16 1:18
Max Fedotov10-Oct-16 1:18 
Questionhow to use Pin
Herilane25-Aug-16 19:22
professionalHerilane25-Aug-16 19:22 
AnswerRe: how to use Pin
Max Fedotov25-Aug-16 20:21
Max Fedotov25-Aug-16 20:21 
GeneralRe: how to use Pin
Herilane30-Aug-16 17:43
professionalHerilane30-Aug-16 17:43 
GeneralRe: how to use Pin
Max Fedotov30-Aug-16 18:03
Max Fedotov30-Aug-16 18:03 
GeneralRe: how to use Pin
Herilane31-Aug-16 1:03
professionalHerilane31-Aug-16 1:03 
GeneralRe: how to use Pin
Max Fedotov31-Aug-16 1:35
Max Fedotov31-Aug-16 1:35 
GeneralRe: how to use Pin
Herilane31-Aug-16 1:52
professionalHerilane31-Aug-16 1:52 
GeneralRe: how to use Pin
Max Fedotov31-Aug-16 2:20
Max Fedotov31-Aug-16 2:20 
GeneralRe: how to use Pin
Herilane31-Aug-16 2:46
professionalHerilane31-Aug-16 2:46 
GeneralRe: how to use Pin
Max Fedotov31-Aug-16 2:35
Max Fedotov31-Aug-16 2:35 
GeneralRe: how to use Pin
Herilane31-Aug-16 3:22
professionalHerilane31-Aug-16 3:22 
GeneralRe: how to use Pin
Max Fedotov31-Aug-16 4:54
Max Fedotov31-Aug-16 4:54 
GeneralRe: how to use Pin
Herilane31-Aug-16 17:55
professionalHerilane31-Aug-16 17:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.