Tuesday, 28 February 2017

Winforms - showing touch keyboard on Win 10

If you're using a textbox in a winforms app on Windows 10 in tablet mode the touch keyboard only seems to show if your textbox is a password box. Weird huh? There's a few proposed solutions for this to do with tabtip.exe or osk.exe but neither of these worked for me. The most effective solution was to:

Insert a reference to UIAutomation.dll
    In the form-load-handler of the application's main window, insert the following code:
      var asForm = System.Windows.Automation.AutomationElement.FromHandle(this.Handle);