Click here to Skip to main content
14,921,505 members
Articles / Desktop Programming / WPF
Tip/Trick
Posted 23 Aug 2016

Stats

41.6K views
4 bookmarked

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 (2 votes)
23 Aug 2016CPOL
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)

Share

About the Author

Max Fedotov
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
Memberthemoscy3-Apr-20 1:10 
Suggestion5* but some issues Pin
Nasenbaaer13-Feb-19 22:35
MemberNasenbaaer13-Feb-19 22:35 
QuestionNon admin user Pin
Member 259687123-Mar-17 7:43
MemberMember 259687123-Mar-17 7:43 
AnswerRe: Non admin user Pin
Max Fedotov24-Mar-17 5:48
MemberMax Fedotov24-Mar-17 5:48 
QuestionUse InputScope="Number" with DataGridTextColumn? Pin
rburrough110-Oct-16 1:22
Memberrburrough110-Oct-16 1:22 
AnswerRe: Use InputScope="Number" with DataGridTextColumn? Pin
Max Fedotov10-Oct-16 1:28
MemberMax Fedotov10-Oct-16 1:28 
GeneralRe: Use InputScope="Number" with DataGridTextColumn? Pin
rburrough112-Oct-16 10:46
Memberrburrough112-Oct-16 10:46 
GeneralRe: Use InputScope="Number" with DataGridTextColumn? Pin
Max Fedotov12-Oct-16 20:03
MemberMax Fedotov12-Oct-16 20:03 
GeneralRe: Use InputScope="Number" with DataGridTextColumn? Pin
rburrough126-Oct-16 10:58
Memberrburrough126-Oct-16 10:58 
GeneralRe: Use InputScope="Number" with DataGridTextColumn? Pin
Max Fedotov26-Oct-16 20:01
MemberMax Fedotov26-Oct-16 20:01 
PraiseThanks Pin
rburrough110-Oct-16 1:13
Memberrburrough110-Oct-16 1:13 
GeneralRe: Thanks Pin
Max Fedotov10-Oct-16 1:18
MemberMax 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
MemberMax 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
MemberMax 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
MemberMax 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
MemberMax 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
MemberMax 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
MemberMax 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.