title: WPF Programatically change row background color with conditions
body: <p>I am trying to use LoadingRow for change row colors programatically. It is working as i need. But the problem is with scrollbar. When i use the scrollbar in datagrid my formula is running again and i am getting silly ordered row colors.</p>
  
  <p>here is my code. i am trying to change colors with 17th columns value.</p>
  
  <pre><code>        private void dataGrid1_LoadingRow(object sender, DataGridRowEventArgs e)
      {
          DataGridRow row = e.Row;
          DataRowView rView = row.Item as DataRowView;
          if (rView != null &amp;&amp; rView.Row.ItemArray[17].ToString().Contains("1"))
          {
              renk++;  
          }
          if (renk % 2 == 0)
          {
              e.Row.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FF0000"));
          }
          else
          {
              e.Row.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#ffffff"));
          }
      }
  </code></pre>
  
  <p>After running of my code it is working. But when i scrolling down my mouse to see following rows it is working also. Then when i scrolling up mouse to see first rows my code does'nt work good. You can see difference between opened time and after scrolling pictures below.</p>
  
  <p><a href="https://i.stack.imgur.com/MUu7L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MUu7L.png" alt="First order is good "></a> <a href="https://i.stack.imgur.com/j2vyG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j2vyG.png" alt="Why it is confusing"></a></p>
  
  <p>Thanks.</p>