在Windows 8 metro中隐藏虚拟键盘

时间:2012-10-29 08:31:11

标签: windows-8

现在我正在使用Windows 8 Metro应用程序。为此,我有一个带文本框和确定按钮的弹出窗口。当在虚拟键盘上单击“Enter”时,我需要隐藏虚拟键盘。如果我点击弹出键盘上的“确定”按钮会自动隐藏。

我得到this Link作为好参考(使用HiddenField)。有没有办法在不使用“HiddenField”的情况下完成这项工作。提前谢谢..

2 个答案:

答案 0 :(得分:4)

好吧终于找到了解决这个问题的方法..我只是在弹出框中将焦点从文本框更改为按钮..下面是示例代码..

public void FocusTextbox(object sender, EventArgs e)
    {
        // set focus to textbox on popup open
        Textbox.Focus(Windows.UI.Xaml.FocusState.Programmatic);
    }

public void Textbox_KeyDown(object sender, KeyRoutedEventArgs e)
    {
        // conforming the "Enter" button click
        if (e.Key == Windows.System.VirtualKey.Enter)
        {
            // change the focus to OK button
            this.OkButton.Focus(Windows.UI.Xaml.FocusState.Pointer);
        }
    }

在关闭弹出窗口之前更改焦点......现在效果很好..
将焦点更改为Label或Textblock并未隐藏虚拟键盘...

答案 1 :(得分:0)

我也在寻找这个,但我先发现this approach

相关问题