2013-03-07 31 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 
    } 
} 
相關問題