I have a simple ViewModel
containing an ObservableCollection
which is bound to the ItemsSource
prop. of a ListView
. On predefined time period the ViewModel
will receive an update (snapshot) - new DataObject
that has the same Id but different value. What i am doing right now is:
- find the index of the item with this id
- if there is no such item: add it to the collection
- if there is - replace it: obsColItems[index] = newDataObject;
I expected the ListView
to reflect the changes but only add operations are visible - subsequent changes (replacing of item) are not visible. I hooked up a CollectionChange
event and it is correctly fired but ListView
still shows the initial data.
Few thing I tried:
1. remove and then insert the item at the appropriate index - that
leaved me with a bad taste in the mouth (it also messed the current
selected item).
2. After bit of research `BindingList` was mentioned in few similar SO questions
and it did the trick - the `ListView` is now updating, but it seams to
be full of functionality I don't relay need.
Is there something wrong with ObservableCollection
and item replacing and how to make ListView
to update after item replace ?