[UWP]TextBox LostFocus not working RRS feed

  • Question

  • Hi. 

    I develop UWP app. I have a textbox, i need event gotfocus and lostfocus. I need at lost focus, changeed property in my viewmodel, but when the focus goes to another element, event lostfocus not working.Why?

     private void TextBox_GotFocus(object sender, RoutedEventArgs e)
                ViewModelMainPage.TextBoxFocus = true;

            private void TextBox_LostFocus(object sender, RoutedEventArgs e)
                ViewModelMainPage.TextBoxFocus = false;

    • Edited by Jayden Gu Thursday, July 6, 2017 5:18 AM title tag
    Wednesday, July 5, 2017 1:45 PM

All replies

  • Hi Vladimir Kombarov,

    The LostFocus event will be fired when you set the focus on other element. Have you add Breakpoint in the LostFocus event? If it does not enter the LostFocus event, please tell us more detail about your OS version of your Windows and your VS SDK.

    Also would you please share us a simple reproduced project, it will help us analyze and diagnose this issue more clearly.

    Best Regards,

    Jayden Gu

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, July 6, 2017 7:25 AM
  • Hi Vladimir,

    Set a break point on the event handler as suggested is a good way to see if the event happened. Besides, could you please also paste the xaml for your TextBox like this?

    <TextBox GotFocus="TextBox_GotFocus" LostFocus="TextBox_LostFocus"></TextBox>

    I build UWPs:  Arrnage Pro Cloud Resource Tool

    • Edited by Saar Shen Saturday, July 8, 2017 5:17 AM
    Saturday, July 8, 2017 5:16 AM