I am facing the following issue. When i am removing the first element from a list box which has keyboard focus(by refreshing the item source) the keyboard focus is moving to the parent window. I want to retain the keyboard focus on the fist listbox item. So i came up with the following code
<Grid.Resources>
<Style TargetType="{x:Type ListBox}">
<Style.Triggers>
<DataTrigger Binding="{Binding FirstRowDeleted}" Value="True">
<Setter Property="FocusManager.FocusedElement" Value="{Binding ElementName=MyListBox}" />
</DataTrigger>
</Style.Triggers>
</Style>
Using this code i am able to move the focus to the list box itself. How can i move the focus to the first listbox item? MyListBox[0] does not seem to work. Any suggestions?
Thanking you Kaddy