Detect keyboard deployment

给你一囗甜甜゛ 提交于 2019-12-12 04:16:53

问题


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:


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.



来源:https://stackoverflow.com/questions/33670158/detect-keyboard-deployment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!