I need to get access to the binding expression of the DataGrid cell in a DataGridTextColumn. For example:
<DataGridTextColumn Header="Name" Binding="{Binding Name}"/>
I managed to get the TextBlock associated with the cell:
var cell = dataGrid.GetCellCtrl<TextBlock>(dataGrid.CurrentCell);
And cell seems to be correct. I can call
cell.SetValue(TextBlock.TextProperty, value);
To update the cell text. It seems to be working on the grid (number updated). However, as I realize after a while, the source doesn't get updated. It didn't help even if I turn UpdateSourceTrigger to PropertyChange. Then, I thought I need to get the binding expression and call UpdateSource explicitly.
var bindingExpr = cell.GetBindingExpression(TextBlock.TextProperty);
but bindingExpr is always null. Why?
EDIT: The original problem I had was that I can get to the binding TextBlock for the cell, and set the TextBlock.TextProperty. However, the source doesn't get updated. This is something I'm trying to resolve this problem.