0

我正在开发一个简单的 Windows Phone 8 应用程序,并使用 Url InputScope 正确显示键盘。在软键盘 (SIP) 的右下角会显示一个右箭头。

如何检测用户单击该按钮?

我已经尝试过 KeyUp 事件,但未定义 Key 类,因此我无法将 e.Key 与 Key.ENTER 进行比较 - 而且我也觉得检查密钥代码是不正确的,从语义上讲. 我宁愿在 HTML 中找到一些“onSubmit”事件。

4

1 回答 1

0

我首先添加了“使用 System.Windows.Input;”。到我的 .cs 文件的顶部。之后,Key 类变得可用。

XAML:

<TextBox KeyUp="txtUrl_KeyUp" x:Name="txtUrl" InputScope="Url"  VerticalAlignment="Stretch" HorizontalAlignment="Stretch" TextWrapping="Wrap" VerticalScrollBarVisibility="Disabled" ManipulationCompleted="txtUrl_ManipulationCompleted" Margin="0,127,0,0" Grid.RowSpan="2" />

C#:

private void txtUrl_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
{
    if (e.Key.Equals(Key.Enter)) {
        navigateTo(txtUrl.Text);
        webBrowser.focus(); // Hides the input box
    }
}
于 2013-03-07T23:13:37.903 回答