Search code examples
c#keyboardwindows-store-appswindows-10

Display touch keyboard in Windows 10 Store App


Whilst testing our Windows Store app developed for Windows 8/8.1 on Windows 10 we've discovered that tapping on a textbox doesn't display the touch keyboard.

I've created a new project to test this in using a textbox defined with the following XAML

    <TextBox x:Name="testTextBox" HorizontalAlignment="Left" Margin="469.901,314.495,0,0" InputScope="Number" 
             TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="37" Width="383" RenderTransformOrigin="0.5,0.5" 
             UseLayoutRounding="False" d:LayoutRounding="Auto"> 
    </TextBox>

It seems InputScope="Number" is having an effect because if I manually open the touch keyboard it is displaying the number keyboard however I can't get the touch keyboard to open when the textbox gets focus (ie. it is tapped on).

I have also tried setting this value through code as follows:

        InputScope scope = new InputScope();
        InputScopeName scopeName = new InputScopeName();
        scopeName.NameValue = InputScopeNameValue.Number;
        scope.Names.Add(scopeName);
        testTextBox.InputScope = scope;

UPDATE I've found there is a setting Tablet Mode which when turned on the touch keyboard does launch as I expected.


Solution

  • It turns out that the touch keyboard will only automatically display if the device is in Tablet mode.

    How To Enable Tablet Mode