I have a ListBox with ItemsSource binding to an ObservableCollection<Item>.
Item has two string properties Name and Description.
DataTemplate for Item is StackPanel with Children: TextBlock with Text Bind to Name, TextBox with Text bind to Description.
What I have now: 1. When cursor is in TextBox corresponding to Description of an item, the corresponding ListBoxItem is highlighted. 2. I can use Tab to navigate among item's Textbox 3. If I move cursor to another named TextBox(theTextBox in code below) outside of listbox, the selected item do not highlight any more. That is my problem.
The png at https://drive.google.com/file/d/1tyxaBLnnjFUCJRTsHbwBwSvdU_X_L1fn/view?usp=sharing help explains my problem.
<DockPanel>
<ListBox ItemsSource="{Binding Items}" DockPanel.Dock="Top" Height="100" KeyboardNavigation.TabNavigation="Cycle">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Focusable" Value="False"/>
<Style.Triggers>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter Property="Background" Value="LightGreen" />
</Trigger>
</Style.Triggers>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<ItemContainerTemplate >
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Name}"/>
<TextBox Text="{Binding Description}"/>
</StackPanel>
</ItemContainerTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TextBox Name-"theTextBox" AcceptsReturn="True" />
</DockPanel>