I need to access the value that underlies the active DataGrid cell (a cell with a black border around it).
Fortunately, the DataGrid has many properties, such as CurrentCell, CurrentItem SelectedCells SelectedItem, and SelectedItems, which seem to provide me with the data I need.
However, I did not understand how easy it is to access the cell. I also changed ...
SelectionMode="Single" SelectionUnit="Cell"
... but in the end I had to do something like this:
DataGridCellInfo cellInfo = dataGrid.CurrentCell;
if(null != cellInfo && cellInfo.IsValid)
{
object[] array = cellInfo.Item as object[];
if (null != array && cellInfo.Column.DisplayIndex >= 0 && cellInfo.Column.DisplayIndex < array.Length)
{
object cellValue = array[cellInfo.Column.DisplayIndex];
if (null != cellValue)
{
}
}
}
, . , cellInfo.Column( ), . , - , , , DataGrid, , .
.
UPDATE
Quartermeister , , . , DisplayIndex, , .