即使焦点更改后的键盘也不会解雇 [英] Keyboard won't dismiss even after Focus change

查看:141
本文介绍了即使焦点更改后的键盘也不会解雇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个Windows应用程序8.1,用户按下一个按钮后,弹出打开超极本屏幕。还有的酥料饼里面几个文本框。

I am creating a Windows 8.1 app and after the user presses a button, a popup opens over most of the screen. There are several textboxes inside the popover.

我发现从微软有关如何检测屏幕上的键盘外观这的示例代码。

我还发现以下SO帖子和网站基本上通知,没有办法强迫键盘关闭,并做了正确的事情,其实是在编程焦点页面上的隐藏元素或禁用,然后重新启用文本框:

I have also found the following SO posts and sites basically informing that there is no way to force the keyboard to close, and the correct thing to do is in fact programmatically focus a hidden element on the page or disable and then re-enable the textbox:

  • Forcing Windows 8 soft keyboard to hide
  • Windows 8 soft keyboard not hidden
  • Show/Hide Keyboard Automatically Widnows 8
  • How to Dismiss Touch Keyboard

于是我跟着建议创建了一个无形的按钮。当用户点击关闭按钮,它应该以聚焦该按钮并关闭键盘。什么情况是文本框的的失去焦点,但键盘不会消失。如果我引起的关闭按钮以聚焦隐藏的按钮关闭弹出窗口(这是预期的效果),键盘不会消失,直到视图(即以前的弹出下)是。窃听

So I followed the advice and created an invisible button. When the user taps the close button, it is supposed to give focus to that button and dismiss the keyboard. What happens is the textbox does lose focus, but the keyboard does not go away. If I cause the close button to give focus to the hidden button and close the popup (which is the desired effect), the keyboard does not go away until the view (that was previously under the popup) is tapped.

我怎样才能使关闭弹出窗口原因键盘驳回

How can I make closing the popup cause the keyboard to dismiss?

修改? 看来,有可能是一个以编程方式取消键盘,因为触发应用栏打开,而keyboardi开放式自动驳回键盘。

It appears that there might be a way to programmatically dismiss the keyboard because triggering the App Bar to open while the keyboardi s open automatically dismisses the keyboard.

推荐答案

在显示虚拟键盘文本框被禁用,它会关闭该虚拟键盘。因此,解决方案是设置文本框属性IsEnabled为false,并再次将其设置为true,这样就可以再次使用。

When the textbox that shows the virtual keyboard was disabled it will dismiss the virtual keyboard. so the solution is set the textbox property IsEnabled to false and set it again to true so it can be use again.

TextBox.KeyDown += (s, a) => {
 if (a.Key == VirtualKey.Enter) {
   TextBox.IsEnabled = false;
   TextBox.IsEnabled = true;
 }

这篇关于即使焦点更改后的键盘也不会解雇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆