C#C
C#3y ago
Cin

MVVM - View model with collection of view models?

Within MVVM, can a view model have a collection of view models?

Is it okay to do:
class BasketViewModel
{
public ObservableCollection<ItemViewModel> Items {get; set;}
}

Please assume ItemViewModel exists somewhere in the code base.

If this is acceptable, where should this collection be initialised from? The constructor or somewhere else?
Was this page helpful?