I
I
igsavenko2015-05-05 08:35:50
WPF
igsavenko, 2015-05-05 08:35:50

How to determine that the ViewModel has been changed from the DataGrid?

Good afternoon,
There is a DataGrid which displays ViewModels from an ObservableCollection. When you change any property from the DataGrid, the ViewModel itself also changes. I want to add a "Save" button, by clicking on which the changed ViewModels should be saved to the database (there everything is more difficult, I will not describe the transfer of data to the server and everything not related to the question). How do I determine that the model has been changed? What is the best way to mark this sign? And after that, I can already take only the changed ViewModel from the collection and transfer them to the server.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2015-05-09
@yarosroman

subscribe to the CollectionChanged event of the collection, in the event parameters you will receive the changed objects of the collection, make another collection into which we save the changes, and when the button is pressed, transfer the changes from this collection.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question