There's a datagrid in my from,and I ues a DataTrigger to set the DataGridCell's foreground color to ensure that it looks clear,just like this:
<Style TargetType="my:DataGridCell">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=State}" Value="0">
<Setter Property="Foreground" Value="Black" />
</DataTrigger>
<DataTrigger Binding="{Binding Path=State}" Value="1">
<Setter Property="Foreground" Value="Green" />
</DataTrigger>
</Style.Triggers>
</Style>
And then I want to set it's StyleTrigger,to make sure they have same background and BorderBrush,just like this:
<Style.Triggers >
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#d4ecff"/>
<Setter Property="BorderThickness" Value="0"></Setter>
<Setter Property="BorderBrush" Value="#d4ecff"></Setter>
</Trigger>
</Style.Triggers>
but then I have a question,when I selected one cell,the cell foreground change White because I didn't set it so it been set a acquiescent color.
I want to achieve this:whichever cell i select,the cell background will change same(#d4ecff),but the foreground will not change:If it's Green,it keeps Green and if it's Black ,it keeps Black.
How Can I do this ? thank you everyone helps me!