Hello,
I am currently modifying row colors in my Grid when the row content meets the specific text that I want. The code works perfectly when the data is not that big. But if I have sufficient number of rows that triggers a scroll bar, every time I scroll down, the color gets assigned randomly to the new rows even if the row did not meet the criteria.
Below is the code.
private void gvMain_RowLoaded(object sender, RowLoadedEventArgs e)
{
var a = e.Row as GridViewRow;
if (a != null)
{
if ((a.Cells[0].Content.ToString() == "Tittle1") || (a.Cells[0].Content.ToString() == "Tittle2") || (a.Cells[0].Content.ToString() == "Tittle3")||(a.Cells[0].Content.ToString()=="Tittle4"))
{
a.Height = 35;
a.Background =
new SolidColorBrush(Colors.LightGray);
a.FontSize = 15;
a.FontWeight=
FontWeights.Bold;
}
else if
//Set row color of cells
((a.Cells[0].Content.ToString() ==
"Private") || (a.Cells[0].Content.ToString() == "Public"))
{
a.Height = 25;
a.Background =
new SolidColorBrush(Colors.Blue);
a.FontSize = 12;
a.FontWeight =
FontWeights.Bold;
}
else
{
a.FontWeight =
FontWeights.Bold;
}
}
}
Please advice