Search code examples
c#windows-10uwpwindows-10-mobile

Detect keyboard deployment


I am porting an WP7 Silverlight application to the UWP Windows 10 mobile platform. In my old code I used to check if the keyboard was deployed in the following way:

if (DeviceStatus.IsKeyboardDeployed)
            {
                // do stuff
            }
            else
            {
                //do stuff
            }

Now I want to do the same in WM10 but there does not seem to be an equivalent of this function anymore. I already checked the following link And Googled but cannot find it.

Does anybody know if you still can detect this in any way?


Solution

  • I think you can make use of InputPane clss, for example like this:

    InputPane pane = InputPane.GetForCurrentView();
    pane.Showing += (s, e) => Debug.WriteLine($"Keyboard {(s as InputPane).Visible}");
    pane.Hiding += (s, e) => Debug.WriteLine($"Keyboard {(s as InputPane).Visible}");
    

    Just subscribe to InputPane attached to your view, you can even make a proberty in your app that will be changed in pane's Showing/Hiding events. Or you can just move your job to those events - this depends on your needs.