wpf的datagrid列选中后改变颜色
程序员文章站
2022-03-01 13:03:59
...
[size=medium]wpf的datagrid列选中后改变颜色[/size]
<UserControl.Resources>
<Style x:Key="CellStyle" TargetType="{x:Type DataGridCell}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="Black"/>
<!--<Setter Property="BorderThickness" Value="0,0,0,0"/>-->
<Setter Property="BorderBrush" Value="Transparent"/>
</Trigger>
<!--<Trigger Property="DataGridRow.IsFocused" Value="True">
<Setter Property="Background" Value="Red" />
</Trigger>-->
</Style.Triggers>
</Style>
<Style x:Key="CellStyle2" TargetType="{x:Type DataGridCell}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Yellow" />
<Setter Property="Foreground" Value="Black"/>
</Trigger>
<Trigger Property="DataGridRow.IsFocused" Value="True">
<Setter Property="Background" Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Resources>