Changing Row Color by specific Condition WPF Datagrid

1.3k views Asked by At

I have the exact same problem as this guy:

How to change row color in datagridview?

The differenence is that i use WPF. So .rows doesnt exist. Does anybody of you have a clue how to solve this?

1

There are 1 answers

0
Tommehh On

I solved it like this:

private void dgAnzeigeKostenstelle_LoadingRow(object sender, DataGridRowEventArgs e)
        {
            try
            {
                if (Convert.ToInt32(((System.Data.DataRowView)(e.Row.DataContext)).Row.ItemArray[5]) > Convert.ToInt32(((System.Data.DataRowView)(e.Row.DataContext)).Row.ItemArray[4]))
                {
                    e.Row.Background = new SolidColorBrush(Colors.OrangeRed);
                } 
            }
            catch
            {
            } 
        }