I'm trying to take WAF as startup for my project. I have such situation - I need to make a collection of ViewModels inside another VM. Just like in demo app of Josh Smith's MSDN article. Here is simplified example of code:
List<CustomerViewModel> list = new List<CustomerViewModel>();
foreach (Customer customer in customersRrepository.GetCustomers())
this.AllCustomers = new ObservableCollection<CustomerViewModel>(list);
But in WAF abstract class ViewModel has only constructors with IView interface as a mandatory parameter. So what is the right way here to do? To get every instance of VM from MEF's container? Something Like this:
customerViewModel = container.GetExportedValue<CustomerViewModel>();
but would it be a good decision to initiate an instance of a View for each VM? I think, it is a some kind of memory waste. I'd prefer to make a datatemplate for collection's item of type CustomerViewModel, I even have no idea, if it possible to use View
stored in a property of item for rendering a whole collection on a form.
Thanks in advance!