如何更新焦点ListView.SelectedItem
内的子控件何时ListView
获得焦点?
<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>
列ListView
中有子控件的GridView
行。ListView.SelectedItem
当任何行中的任何子控件具有键盘焦点时,我想更新绑定属性。如果这可以完全在.xaml
文件中完成,而不必求助于代码隐藏,那就太好了。