title: Change DataGridRow color according to min value
body: <p>I have made a UI which contains a <code>Button</code> and a <code>DataGrid</code>. I have made a few calculations in the code that generate four lists which look like this:</p>
  
  <pre><code>var L = new List&lt;MyDataObject&gt;();
  for (int z = 0; z &lt; list_Exp.Count; z++)
  {
      var d = new MyDataObject();
  
      d.AmountNeed = Math.Ceiling((goalexp - currentexp) / (list_Exp[z]));
      d.TotalLose = d.AmountNeed * (list_Amount_MadeFrom_One[z] * list_BuyPrice_MadeFrom_One[z] + list_Amount_MadeFrom_Two[z] * list_BuyPrice_MadeFrom_Two[z]);
      d.TotalGain = d.AmountNeed * list_AmountMade[z] * list_SellPrice[z];
      d.TotalCost = d.TotalGain - d.TotalLose;
  
      L.Add(d);
  }
  </code></pre>
  
  <p>Once I got the lists I find the min value in a specific list:</p>
  
  <pre><code>int i = L.FindIndex(x =&gt; x.TotalCost == L.Min(y =&gt; y.TotalCost));
  </code></pre>
  
  <p>And add all the lists into <code>dataGrid</code>:</p>
  
  <pre><code>dataGrid.ItemsSource = L;
  </code></pre>
  
  <p>Now, I have been trying to change the color of <code>Rows[i]</code> to green or any other color. I have tried stuff like:</p>
  
  <pre><code>grid.Columns["NameOfColumn"].DefaultCellStyle.ForeColor = Color.Gray;
  </code></pre>
  
  <p>or</p>
  
  <pre><code>dataGrid.Rows[rowIndex].Cells[columnIndex].Style.BackColor = Color.Red;
  </code></pre>
  
  <p>and nothing works.</p>
  
  <p>Thank You.</p>