[英]Hide keyboard Windows Phone 8.1
When I try to add a text in the TextBox from a canvas using handwriting, the cursor go to the TextBox and the keyboard shows, and I try to add some code like make the TextBox isReadonly or trying to hide the keyboard and doesn't work. 当我尝试使用手写方式从画布上在TextBox中添加文本时,光标移至TextBox并显示键盘,并且尝试添加一些代码,例如使TextBox为ReadReadonly或试图隐藏键盘而无法正常工作。 I want every time select an item from the ListBox the item add to the TextBox without showing the keyboard.
我想每次从ListBox中选择一个项目,然后将该项目添加到TextBox中而不显示键盘。 the action on RecognizedListBox_SelectionChanged a ListBox
对RecognizedListBox_Selection的操作更改了ListBox
private void RecognizedListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (RecognizedListBox.SelectedItem == null)
return;
//gte the selected item from listbox
string inputTextWritePad = RecognizedListBox.SelectedItem.ToString();
//add the item to RichEditBox
MyTextNote.Text += inputTextWritePad + " ";
//clear the canvas return the listbox to vide
ClearAllClick(sender, e);
}
If I add isReadonly for TextBox, it will permanent disable to edit it, and I can't add any text using keyboard. 如果为TextBox添加isReadonly,它将永久禁用对其进行编辑,并且我无法使用键盘添加任何文本。 I don't know where I will put my code, or verify when I need the keyboard to use it.
我不知道将代码放在哪里,或者不知道何时需要键盘才能使用它。 I see if I need to hide the keyboard, I must have an event for the keyboard button or something like this
我看是否需要隐藏键盘,我必须为键盘按钮或类似事件创建一个事件
private void TextBox_KeyUp(object sender, KeyRoutedEventArgs e)
{
if(e.Key==Windows.System.VirtualKey.Enter)
{
Windows.UI.ViewManagement.InputPane.GetForCurrentView().TryHide();
}
}
but nothing to figure out!! 但没什么好说的!!
update 1: I add this code 更新1:我添加此代码
private void MyTextNote_GotFocus(object sender, RoutedEventArgs e)
{
InputPane.GetForCurrentView().TryHide();
}
and help me to not show the keyboard, but I need to show it when I clicked the textbox, I try whit tapped but nothing help. 并帮助我不显示键盘,但是当我单击文本框时需要显示它,我尝试轻按一下,但没有任何帮助。
Here's a property to avoid displaying Keyboard if your TextBox receives focus programmatically : 如果TextBox以编程方式获得焦点,这是一个避免显示Keyboard的属性:
<TextBox PreventKeyboardDisplayOnProgrammaticFocus="true"/>
Set this property to true to prevent the onscreen touch keyboard from showing when focus is programmatically set on a text box.
将此属性设置为true可以防止以编程方式在文本框上设置焦点时显示屏幕触摸键盘。 By default, the onscreen touch keyboard is displayed whenever focus moves to an editable text box and the most recent input was generated by touch.
默认情况下,只要将焦点移至可编辑的文本框并且触摸产生了最新输入,就会显示屏幕触摸键盘。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.