[英]Close keyboard on tapping on Enter
我使用Windows Phone 8的工具包,并在页面上显示了AutoCompleteBox。
现在,如果用户在不选择当前项目的情况下将一些内容写入AutoCompleteBox,则我想关闭键盘(意味着用户在其他文本中键入内容),并使用“ Return”提交文本。
如何才能做到这一点?
你可以做这样的事情,
<AutoCompleteBox Name="Input" KeyUp="Input_KeyUp" FontSize="40">
<AutoCompleteBox .InputScope>
<InputScope>
<InputScopeName />
</InputScope>
</AutoCompleteBox .InputScope>
</AutoCompleteBox >
而且在事件上
private void Input_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
this.Focus();
}
}
在此处阅读全文: Dismiss the SIP (keyboard) in WP8
您可以使用KeyUp事件处理程序关闭键盘,然后选择当前页面的Focus():
void textBox_KeyUp(object sender, KeyEventArgs e)
{
// if the enter key is pressed
if (e.Key == Key.Enter)
{
// focus the page in order to remove focus from the text box
// and hide the soft keyboard
this.Focus();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.