MVVM EntityFramework 4.1 Master-Details. How can i update an ObservableCollection<T> when T is saved using EF and Repository+UOW
Posted on 2013-01-02
I have a View that has a listbox whose ItemsSource is an ObservableCollection<T>.
T is a ViewModel (called PersonViewModel) wrapping a poco class (called Person). The PersonViewModel has a SaveCommand and Validation code.
The ListBox selected item is used as the Datacontext for a details view.
The details view shows the single (selected) PersonViewModel and uses the SaveCommand to save any changes, made in the details view, to the wrapped person poco.
The Save command will save the data to SqlServer database using repository Insert, and saving changes the entitys state from Modified to Unchanged.
This doesn't seem to update the ObservableCollection because when I press the Save button again, the entity can be saved again (because its state in the ObservableCollection remains as Modified).
Can you give me any pointers re how to keep the state of ObservableCollection of Person entities synchronized with what the Context thinks is happening.