Skip to content

Instantly share code, notes, and snippets.

@HamGuy
Created July 31, 2013 09:28
Show Gist options
  • Save HamGuy/6120693 to your computer and use it in GitHub Desktop.
Save HamGuy/6120693 to your computer and use it in GitHub Desktop.
Windows Phone开发 TextBox的回车事件 关闭软键盘 单行的TextBox,如果用户按回车键,说明输入已经完成,但Windows Phone并不会自动隐藏软键盘盘.单行的TextBox在按回车键后会触发TextInput事件,而TextBox在失去焦点后,软键盘就会隐藏,所以重写这个事件的方法,把焦点转移到其他控件上即可:
private void textBox1_TextInput(object sender, TextCompositionEventArgs e)
{
System.Diagnostics.Debug.WriteLine(textBox1.Text);
this.Focus();
//转移焦点到整个页面,TextBox失去焦点后,就会隐藏软键盘
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment