Reputation: 4560
I am trying to turn off the isReadOnly property of a WPF Datagrid cell via c#. I need to do this once a user clicks on a row.
I have this so far
private void dgProductItem_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
DataGrid dg = sender as DataGrid;
if (dg != null)
{
DataGridRow dgr = (DataGridRow)(dg.ItemContainerGenerator.ContainerFromIndex(dg.SelectedIndex));
}
}
But how do I get down to the cell level via the
DataGridRow
So finally I am looking for cell.ISReadOnly = false/true;
Cheers
Upvotes: 1
Views: 1519
Reputation: 6641
If you want to work on the DataGridCell
object, you are going to need a little bit more code than expected
Check the answer here and use the TryTofindGridCell
method to retrieve the DataGridCell
object and then set its IsreadOnly
property
Alternatively you can also check the solution described here to retrieve DataGridRow
s / DataGridCell
Upvotes: 3