I need to access the binding expression of a DataGrid cell in a DataGridTextColumn. For instance:
<DataGridTextColumn Header="Name" Binding="{Binding Name}"/>
I managed to get the associated TextBlock cell:
var cell = dataGrid.GetCellCtrl<TextBlock>(dataGrid.CurrentCell);
And the cell seems right. I can call
cell.SetValue(TextBlock.TextProperty, value);
To update cell text. It seems to be working on a grid (number updated). However, as I understand it, after a while, the source is not updated. This did not help even if I return the UpdateSourceTrigger to the PropertyChange. Then I thought that I needed to get the binding expression and explicitly call UpdateSource.
var bindingExpr = cell.GetBindingExpression(TextBlock.TextProperty);
but bindingExpr is always null. Why?
EDIT: The initial problem I ran into was that I can go to bind TextBlock to a cell and set TextBlock.TextProperty. However, the source is not updated. This is what I'm trying to solve this problem.
source share