I have two instances of
DataGrid
on the same screen in a master-detail relationship.
The master
DataGrid
shows sections in an estimate and the detail
DataGrid
shows individual cost-items in the section. The master has a column that shows the subtotal for the section.
When I edit a cost-item value in the detail
DataGrid
, I obviously want the subtotal column on the master
DataGrid
to reflect this but I can't figure out how to get it to do this.
Elsewhere on the screen, I have a total for all the subtotals in all the sections (i.e. a grand total) and this is updated immediately, which is what I would expect because any changes in the model layer cause an event handler in the view-model to perform the following call with an empty string as parameter:
protected void OnPropertyChanged( [CallerMemberName] string propertyName = "" )
{
PropertyChanged?.Invoke( this, new PropertyChangedEventArgs( propertyName ) );
My understanding is that firing the
PropertyChanged
event with an empty property name tells the binding engine to update all bindings, and indeed this does always seem to have been the case in the application so far.
How can I get a value in a cell of the master
DataGrid
to recognise that the value to which it is bound has changed? Is there a recognised way to do this?
What I have tried:
I've done a lot of looking for an answer to this but none seems to address the exact scenario I have above. I am surprised because this doesn't seem like an uncommon requirement to me.
I have also been thinking about hacking together something using event handlers in the UI layer but that's exactly what it feels like - hacking. There has to be a more elegant way?