Reputation: 516
I want to change the color of the foreground of a DataGridCell in a DataGrid when the background is anything but white. So I wrote this xaml:
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="Foreground"
Value="White" />
<Style.Triggers>
<DataTrigger Binding="{Binding Background, RelativeSource={RelativeSource Self}}"
Value="Transparent">
<Setter Property="Foreground"
Value="Black" />
</DataTrigger>
</Style.Triggers>
</Style>
Using a converter to test the input and binding, I can see the correct values being generated by the binding. However, the setter does not appear to fire.
edit1: I am setting the cell background color via a converter
edit2: Actually, the background of the textblock of the datagridcell is being set via a converter
Upvotes: 0
Views: 816
Reputation: 516
I set the background of the TextBlock inside the DataGridCell via a converter. So the background of the DataGridCell isn't actually being changed, which is what I bound to.
Upvotes: 0