更新时间:2022-04-04 02:57:02
以下 Style
将更改如果 CheckBox
被检查,背景
颜色的单元格
The following Style
will change the Background
color of the Cell
if the CheckBox
is checked:
<Style x:Key="CheckBoxCellStyle" TargetType="DataGridCell">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<CheckBox x:Name="cb"
IsChecked="{Binding FSCP, UpdateSourceTrigger=PropertyChanged}"
VerticalAlignment="Center"
HorizontalAlignment="Center" />
</DataTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding FSCP, UpdateSourceTrigger=PropertyChanged}" Value="True">
<Setter Property="Background" Value="Blue"/>
</DataTrigger>
</Style.Triggers>
</Style>
<DataGridTemplateColumn Header="FSC-P" Width="SizeToHeader" CellStyle="{StaticResource CheckBoxCellStyle}"/>