locked
[UWP] TextBox and KeyBoard RRS feed

  • Question

  • Hi!

    I'm faced with some problem and don't know how to do better. So i have textbox and some button, i need when i type text and than click this button doesn't hide keyboard in Windows Phone. Now i check when textbox lost focus and if button get this focus return focus to textbox, but it does not always work. How can i fix current problem with lost focus?

    Best regards, Dmitriy



    Tuesday, July 12, 2016 12:25 PM

Answers

  • Hi Dmitiy Yeremenko,

    We can add the click event of the Button, and use Control.Focus method to make the TextBox to get focus in the click event. The KeyBoard will be  shown.

    For example:

    <TextBox Name="MyText" HorizontalAlignment="Center" VerticalAlignment="Center" Width="200" Height="50"></TextBox>
    <Button Content="Click" Click="Button_Click"></Button>

    Code behind:

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        MyText.Focus(FocusState.Pointer);
    }
    If this can not help to fix the current problem with lost focus, please tell us. 

    Could you please describe more about your problem/issue? For example how often will it throw the exception? It will be better if you can share us a simple reproduced project, it will help us analyze and diagnose this issue more clearly.

    Best Regards,

    Jayden Gu


    • Edited by Jayden Gu Wednesday, July 13, 2016 6:44 AM
    • Proposed as answer by Jayden Gu Wednesday, July 20, 2016 9:03 AM
    • Marked as answer by Barry Wang Friday, July 22, 2016 3:01 AM
    Wednesday, July 13, 2016 6:44 AM