Search This Blog

Wednesday, December 14, 2016

Set DataGrid DataGridRow Background color WPF

WPF > DataGrid > DataGridRow > Background


<DataGrid.RowStyle>
  <Style TargetType="DataGridRow">
    <Style.Triggers>
      <DataTrigger Binding="{Binding IsValid}" Value="true">
        <Setter Property="Background" Value="Green"></Setter>
      </DataTrigger>
      <DataTrigger Binding="{Binding IsValid}" Value="false">
        <Setter Property="Background" Value="Red"></Setter>
      </DataTrigger>
    </Style.Triggers>
  </Style>
</DataGrid.RowStyle>