Hello. There is an ObservableCollection that binds to a DataGrid. There is a calculated field in the table. Those. Column3 = Column1 + Column2

How to update a datagrid or collection, or what? so that after you enter Column1 and Column2, the value of Column3 changes immediately?

Thank you in advance!

    2 answers 2

    Since you already wrote the MVVM tag: the value change should be in your VM. In the VM class responsible for the ObservableCollection element, subscribe to changes in the values ​​of Column1 and Column2 , and update Column3 accordingly.

    View just automatically picks up the changes made in the VM.

    • Naturally, changes in the VM. But these changes are not updated in the UI, in particular, the DataGrid. The data model is generated by the Entity Framework. - NekoSin4eG
    • And where is the model? You have an ObservableCollection of non-model elements, hopefully? - VladD
    • @VladD No, I just needed to implement a calculated field at the model level and then everything works.) - NekoSin4eG
    • @ NekoSin4eG: why did this help? It should not have been. Show your VM class that implements the DataGrid line. - VladD

    Implemented the INotifyPropertyChanged interface in the data model and made the required field computable.