You can use code similar to this to select a cell:
var dataGridCellInfo = new DataGridCellInfo(
dataGrid.Items[rowNo], dataGrid.Columns[colNo]);
dataGrid.SelectedCells.Clear();
dataGrid.SelectedCells.Add(dataGridCellInfo);
dataGrid.CurrentCell = dataGridCellInfo;
I can't see a way to update the contents of a specific cell directly, so in order to update the content of a specific cell I would do the following
// gets the data item bound to the row that contains the current cell
// and casts to your data type.
var item = dataGrid.CurrentItem as MyDataItem;
if(item != null){
// update the property on your item associated with column 'n'
item.MyProperty = "new value";
}
// assuming your data item implements INotifyPropertyChanged the cell will be updated.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…