Is there any way to change cell or column background or foreground colours?
I passed a valid DataRecord and Field to CellValuePresenter.FromRecordAndField, but it returned null value. What do you think might go wrong?
Yes,
Then you can use the other static method of the CellValuePresenter:
CellValuePresenter.FromRecordAndField(...);
Thanks. Before I set the IsSelected property of a cell, how could I locate to that cell in procedural code? Is there any example to select a cell like this cell[5][6] (5 is the row number, 6 is the column number)?
If you want to select a cell in procedural code, you can set the IsSelected property of that cell.
If you want to change the background of a cell in procedural code, you have to get the CelLValuePresenter for that cell with the following line:
CellValuePresenter.FromCell(...); and then set the background of that presenter.
However, this color will not be persistet when the cell is scroll out and then back into view, because of the virtualization techniques as the CVP is being destroyed and then recreated.
For this, you can create a style for the CVP and control this with trigger (for the IsSelected property) and change the background.
Could any one confirm with me if it is possible to select a cell dynamically (how to select?) in c# code and change the background or foreground colour of that cell (how to change?), after the datagrid is displayed?
If yes, could any one tell me how to do it or show an example? If no, could I ask this as a new feature for the next release of the datagrid.
This functionality is very important to my project. Please DO reply my question, even the answer is no!
Many thanks.