I am having problems changing the color of the DataGrid rows, I use the following function
int i = 0;
private void gvDados_LoadingRow(object sender, DataGridRowEventArgs e)
{
DataGridRow rowContext = e.Row;
if (rowContext != null)
{
string Situacao = dt.Rows[i]["Situacao"].ToString();
if (Situacao.Equals("V"))
{
SolidColorBrush brush = new SolidColorBrush(Color.FromArgb(100, 255, 104,0));
rowContext.Background = brush;
}
else
{
SolidColorBrush brush = new SolidColorBrush(Color.FromArgb(100, 255, 232,0));
rowContext.Background = brush;
}
i++;
}
}
So far so good, I can adjust the colors according to what I want, the problem in question is when I use the Horizontal Scroll Bar to go down the registers or climb, then all the colors are misconfigured appearing at random. How can I solve this problem so things do not change when scrolling?