Darf
Darf

Reputation: 2585

How can I change the row's background in datagrid?

I have a doubt, I'm still learning WPF.

I'd like to change the background color ina a datagrid depending of a class value. For example:

public class Animal
{
     public bool CanFly { get; set; }
}

Depending of CanFly value in Animal, must choice if the color is green o red (it's just an example). I'm not sure if I must use a style or a value converter. Which of them is most convenient?

Upvotes: 0

Views: 109

Answers (1)

brunnerh
brunnerh

Reputation: 185489

Just use a Setter for the default and a DataTrigger to change it as necessary, converters are for conversion, not triggering. Use the RowStyle to add those to your rows.

Upvotes: 2

Related Questions