I\'m having trouble understanding how to apply the MVVM pattern when Lists/Collections are involved.
Say the MainModel
has a few properties and methods, as
You are right to have a separate DetailModels
list and DetailViewModels
list. The DetailViewModels list should be a property of type ObservableCollection
. You can populate the observable list when you set the Model (or at construction time, if you pass the model into the constructor of your ViewModel.)
private ObservableCollection m_details;
public IEnumerable Details
{
get { return m_details; }
}
You can the subscribe to m_details.CollectionChanged. This is where you can handle re-ordering the contents of the list in the Model.
I hope this helps.