2013-03-07 35 views
0

我正在开发一个简单的Windows Phone 8应用程序,并使用Url InputScope正确显示了键盘。在软键盘(SIP)的右下角显示一个右箭头。当用户在Windows Phone上完成文本输入时的默认操作8

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

我试过KeyUp事件,但没有定义Key类,所以我无法将e.Key与Key.ENTER进行比较 - 而且我也有一种感觉,认为它不正确代码,从语义上讲。我宁愿找到像HTML一样的“onSubmit”事件。

回答

0

我通过首先添加“using 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 
    } 
} 
相关问题