With the DataGrid there is the following problem - the DataGrid has IsReadOnly = "False", but I need to make some cells and rows not editable, but accessible for selection. For DataGridCell and DataGridRow, I couldn’t programmatically restrict editing via IsReadOnly. I’ve been able to restrict editing via IsEnabled, but then I cannot select a cell (row) even if I explicitly set row. IsHitTestVisible = true:

DataGridRow row = (DataGridRow)dataGrid.ItemContainerGenerator .ContainerFromIndex(1); row.IsEnabled = false; row.IsHitTestVisible = true; 

How can I programmatically prohibit editing, but not prohibit the selection of a cell or row?

  • It seems that this is impossible. The editability is set either at the level of the entire DataGrid, or at the level of individual columns (when they are created). The exit - to prohibit editing at the level of the whole table and to provide a separate view for editing entities - Andrey NOP

1 answer 1

One of the crutch options is to make the inside of each cell a TextBox and have IsEnabled = false. in rows or columns IsEnabled = false. As a result, we cannot edit the TextBox, we can edit the Cell (but there the TextBox, therefore, it cannot) and we can select the same row, cells and columns (because we influence the internal content, not the lines and columns themselves).

But this is an extreme crutch as for me.