MEFedMVVM injects Services into ViewModels but...

Oct 28, 2010 at 7:43 PM

Where do you see the deploy scenario of MEFedMVVM injecting a model into a ViewModel?

I think you have a good suggestion Marlon being an experienced wpf user.

 

I have a "CustomerViewModel" hat gets its customer model injected via Ctor injection when the viewmodel is created.

I also do service injection in the CustomerViewModel Ctor because when a property changes of the CustomerViewModel I use

the service to make database updates of the changed property like firstname, lastname etc....

 

MEFedMVVM is usually used for single ViewModels datatemplating a view. But what about the scenario where I have

aggregated ViewModels like CustomerViewModel has Many DocumentViewModels. 2 aggregated ObservableCollections

bound to the View via "BillingViewModel". The BillingViewModel is that typical viewmodel I would use MEFedMVVM for. I call it rather 

a controller. But what about the viewmodel collections where I need to do customerService.UpdateCustomer(FirstName); in the CustomerViewModel

and I have 1000 CustomerViewModels means 1000 services injections... how do you handle such a scenario with MEFedMVVM ?

 

Coordinator
Oct 29, 2010 at 5:53 AM

I am not sure I understand your scenario .... if you do not want different instances of the ViewModel you can Share it... you can use the attached property called ViewModelLocator.SharedViewModel and MEFedMVVM will always use the same ViewModel

Oct 30, 2010 at 6:24 PM

I must try some things first like injecting my model into the ViewModel not via constructor injection but via property injection. If everything works fine, else I come back here how to use all that stuf with MEFedMVVM :)