Detect keyboard deployment

时间:2015-11-12 11:13:30

标签: c# windows-10 uwp windows-10-mobile

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?

1 个答案:

答案 0 :(得分:1)

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.