How can I prevent the keyboard from hiding after the TextBox has lost focus?

I am developing a Windows Phone 8.1 Chat Application in C # as a Windows Runtime Application. I will not mimic the behavior found in applications such as Skype or Facebook Messenger for Windows Phone, where after typing your message and pressing the send button in the AppBar, the keyboard remains in place and you can continue to type the next message.

What I have done so far:

I tried to set focus back to the TextBox in the submit button event handler like:

private async void AppBarButtonSendMessage_Click(object sender, RoutedEventArgs e)
{
    TextBox tb = FindChildControl<TextBox>(ChatSection, "TextBoxMessage") as TextBox;
    tb.Focus(Windows.UI.Xaml.FocusState.Programmatic);

    if (await HttpHelper.SendMessage(tb.Text))
    {
        RefreshMessages();                
        tb.Text = "";
    }
} 

      

(The TextBox is in hub control, so I use the method FindChildControl

.)

So the keyboard disappears for a second and then reappears, which is annoying. How can I avoid this behavior?

+3


source to share





All Articles