In MVVM pattern I don't want to think about the view while creating the model. So I use public properties with data stored in ILists and so on. But then my viewmodel isn't informed of changes done to these lists on model side. Should I use ObservableCollections in my model instead? But this seems strange to me.
2 Answers
4
votes
Yes, you should use ObservableCollections. I don't know what would be strange about this? All an ObservableCollection does is notify any listeners of changes. That doesn't necessarily have to be a UI.
Your ViewModel shouldn't know anything about the actual View using it, but as it's a ViewModel, it is ok for it to assume something is going to use it, so ObservableCollection is the way to go and also, as far as i know, common practice.
Also, the listeners know exactly which items have been added or removed, so there's no need to update the entire list when changes occur => better performance for updates. That's also what Microsoft says (can't find the article about that right now though)