wpf DataGrid cell 背景色修改参考
<DataTemplate.Triggers> <DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType=DataGridRow}}" Value="True"> <Setter TargetName="TextBoxStackPanel" Property="Background" Value="White"/> </DataTrigger> <DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType=DataGridCell}}" Value="True"> <Setter TargetName="TextBoxStackPanel" Property="Background" Value="White"/> </DataTrigger> </DataTemplate.Triggers>
以上分别为行选中和单元格选中时触发
TextBoxStackPanel为 DataTemplate 下的子元素StackPanel的Name