检测键盘部署 [英] Detect keyboard deployment
问题描述
我正在将 WP7 Silverlight 应用程序移植到 UWP Windows 10 移动平台.在我的旧代码中,我曾经通过以下方式检查键盘是否已部署:
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
}
现在我想在 WM10 中做同样的事情,但似乎不再有这个功能的等价物了.我已经检查了以下 link然后用谷歌搜索却找不到.
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?
推荐答案
我认为你可以利用 InputPane clss,例如这样:
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}");
只需订阅附加到您的视图的 InputPane,您甚至可以在您的应用程序中创建一个探测器,该探测器将在窗格的 Showing/Hiding 事件中更改.或者您可以将您的工作转移到这些活动上 - 这取决于您的需求.
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.
这篇关于检测键盘部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!