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