I've been trying to create a method that sets a particular cell to readonly (along with changing the background color). I want something like:
public void SetCellToReadOnly(int rowIndex, int columnIndex) { ((DataRecord)myXamDataGrid.Records[rowIndex]).Cells[columnIndex].ReadOnly = true; ((DataRecord)myXamDataGrid.Records[rowIndex]).Cells[columnIndex].Background = Brushes.Grey;}
What would be the easiest way to achieve this?
Thank you,Mike
I figured it out - here is the end result if anyone wants to know:
private Brush readOnlyColor = (Brush)new BrushConverter().ConvertFrom("#EEEEEE");//Light shade of graypublic void SetCellToReadOnly(int rowIndex, string columnName) { CellValuePresenter.FromCell(((DataRecord)myXamDataGrid.Records[rowIndex]).Cells[columnName]).IsEnabled = false; CellValuePresenter.FromCell(((DataRecord)myXamDataGrid.Records[rowIndex]).Cells[columnName]).Background = readOnlyColor;}
Mike
That works thankx Mike!