Hi, I make a next button on a tabitem, so when user click it, it set focus to the next tabItem and focus on a particular TextBox but the focus setting on the TextBox, doesn't work
here is the code's sample
XAML
<TabControl><TabItem x:Name="Item1" Header="tabItem1"><TextBox x:Name="txtName" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,50,0,0" width="100" height="25" /><Button x:Name="btnNext" Content=" Next " VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,75,0,0" Height="35" Click="bntNext_Click"/></TabItem>
<TabItem x:Name="Item2" Header="tabItem2"><TextBox x:Name="txtProfession" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,50,0,0" width="100" height="25" /><TextBox x:Name="txtCompany" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,75,0,0" width="100" height="25" /></TabItem>
<TabItem x:Name="Item3" Header="tabItem3"><TextBox x:Name="txtEmail" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,50,0,0" width="100" height="25" /></TabItem></TabControl>
VB.NET
Private Sub btnNext_Click(sender As Object, e As RoutedEventArgs) Item2.IsSelected = True 'I also try 'Item2.focus() If Not txtCompany.IsFocused Then 'here I want to set Focus on txtCompany txtCompany.Focus() 'I also Try 'Keyboard.Focus(txtCompany) 'Dispatcher.BeginInvoke(DirectCast(Sub() txtCompany.Focus(), System.Threading.ThreadStart)) End If End Sub
How can I fix this issue