Cin
Cin
CC#
Created by Cin on 12/6/2023 in #help
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;}
}
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?
17 replies