I'm trying to set different colors to different rows in datagrid, based on Type of the row and whether it is selected:
<Style TargetType="DataGridCell" x:Key="ActiveCellStyle">
<Setter Property="Foreground" Value="Black"/>
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Type}" Value="0"/>
<Condition Property="IsSelected" Value="False"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" Value="#FFDFE6ED"/>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Type}" Value="0"/>
<Condition Property="IsSelected" Value="True"/>
</MultiDataTrigger.Conditions>
<Setter Property="Background" Value="#FF6CAFF1"/>
</MultiDataTrigger>
...
</Style.Triggers>
</Style>
When I run this, I'm getting ArgumentException: key cannot be null.
How can I fix this?
With
MultiTrigger
you useProperty
and withMultiDataTrigger
you useBinding
, you can't combine them. So changeto
and it should work