Reputation: 172
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. I want every time select an item from the ListBox the item add to the TextBox without showing the keyboard. the action on RecognizedListBox_SelectionChanged a 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. 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
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.
Upvotes: 0
Views: 1080
Reputation: 965
Here's a property to avoid displaying Keyboard if your TextBox receives focus programmatically :
<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. 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.
Upvotes: 3