How to udpate the ListView.SelectedItem
when a child control within the ListView
gets focus?
<ListView ItemsSource="{Binding Path=Records, Mode=TwoWay}" IsSynchronizedWithCurrentItem="True">
<ListView.SelectedItem>
<Binding Path="SelectedRecord" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged"/>
</ListView.SelectedItem>
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Style.Triggers>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter Property="IsSelected" Value="True"/>
</Trigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
<ListView.Resources>
<DataTemplate DataType="x:Type ListViewItem">
<ListViewItem IsSelected="{Binding IsKeyboardFocusWithin"/>
</DataTemplate>
</ListView.Resources>
<ListView.View>
<GridView>
<GridViewColumn>
<TextBox ... Tag="{Binding}".../>
</GridViewColumn>
<GridViewColumn>
<TextBox ... Tag="{Binding}".../>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
The ListView
has rows of child controls within the GridView
columns. I want to update the bound property of the ListView.SelectedItem
when any of the child control in any row has the keyboard focus. It will be great if this could be entirely done within the .xaml
file without having to resort to the code-behind.