【发布时间】:2014-05-13 20:03:48
【问题描述】:
我的 Windows Phone 8.1 应用商店应用项目(不是 Silverlight)中有一段按钮代码:
private void CursorRightButton_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrWhiteSpace(QueryTextBox.Text)) return;
QueryTextBox.Focus(FocusState.Keyboard); //also i tried FocusState.Pointer
QueryTextBox.Select((TextBox.SelectionStart + 1) % (TextBox.Text.Length + 1), 0);
}
如您所见,我试图以编程方式在文本中向右移动光标,问题是它隐藏了软键盘,然后在点击按钮后再次显示它。我需要在点击此按钮时打开键盘。
我尝试为 sender 和 TextBox 对象修改 Focus() 方法,但找不到任何可能的解决方案。
所以问题是,你如何强制键盘在点击控件时不失去焦点/不隐藏?
【问题讨论】:
标签: c# button windows-phone-8 cursor windows-phone-8.1