Reputation: 275
I have following Problem:
I have two tabs in my TabControl and if the second Tab "TabControl1_Products" is selected I want to set the focus in the "Products_TextBox2" TextBox. I wrote this code, which in theory should work, but it somehow does not...
private void TabControl1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (TabControl1_Products.IsSelected)
{
this.Products_TextBox2.Focus();
}
}
I checked, that the Program enters the if query, but it does not change the focus to the TextBox
Upvotes: 0
Views: 458
Reputation: 1041
You could use a Dispatcher:
Dispatcher.BeginInvoke(DispatcherPriority.Background,new Action(() => thi.Products_TextBox2.Focus()));
Upvotes: 3