I have a DataGrid in a form in C # WPF, how can I execute a method retrieve each cell contained in that DataGrid and assign a possible value, or change the background color?
For example I have a DataGrid:
[ A ] [ D ] [ C ] [ C ]
[ B ] [ A ] [ B ] [ A ]
[ C ] [ A ] [ B ] [ D ]
And then I want to make a loop of repetition:
for (i<TamanhoDeLinhas) // Andar Linha
for(j<TamanhodeColunas) // Andar Coluna
if(DataGrid[i][j].Conteudo == A)
DataGrid[i][j].BackGround = Color.Red;
Is it possible to do this?
Or, I have the corresponding values of I J, that is, I know in which position the values will be! I have to change the background of the cell in Line i = 2 and j = 3. How can you do that? Retrieve the cell and assign a new color according to your position or reading one by one?
The DataGrid in question is bound to a DataTable and it generates the columns and rows automatically, in case it is dynamic. so I do DataGrid.SourceItems = DataTable.DefaultView ... And so I play all the items for the DataGrid.
Either solution is valid.