0
votes

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.

1
If you are okay with disabling your TextBox, why not use a Label instead?yoogeeks
I don't want to disable my textbox, I use a handwriting recognition to add some word, if there are some mistaken word, I want try to modify it, so I need the textboxAmin
try setting focus off your TextBox.yoogeeks
This doesn't work in WP 8.1 app. only Windows.UI.ViewManagement.InputPane.GetForCurrentView().TryHide();Amin
I found this interesting property link which should help you : <TextBox PreventKeyboardDisplayOnProgrammaticFocus="bool"/>yoogeeks

1 Answers

3
votes

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.

Official Doc