You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I stumbled across this when trying to fit my MEF samples to the Prism 6.0 code base using the ViewModelLocator.AutoWireViewModel . I have a single [ImportingConstructor] for my View Model with one parameter (my business service), but the ViewModelLocationProvider is using Reflection to get the View Model instantiating it with the default constructor. Therefore when the module attempts to display my view, I get this exception. "No parameterless constructor defined for this object." Should the ViewModelLocationProvider be using DI to get the View Model instance instead of Reflection?
The text was updated successfully, but these errors were encountered:
karlfl
changed the title
ViewModelLocatorProvider should use DI instead of Reflection to create instances
ViewModelLocationProvider should use DI instead of Reflection to create instances
Jun 1, 2015
BY default, the VML does not use DI, because that would be creating a dependency on a specific Container that you may not want to be using. So, by default we use reflection. But, if you want o use DI, then you can easily use your own container of choice by overriding the SetDefaultViewModelFactory method. So if you want to use MEF, you can.
I stumbled across this when trying to fit my MEF samples to the Prism 6.0 code base using the ViewModelLocator.AutoWireViewModel . I have a single [ImportingConstructor] for my View Model with one parameter (my business service), but the ViewModelLocationProvider is using Reflection to get the View Model instantiating it with the default constructor. Therefore when the module attempts to display my view, I get this exception. "No parameterless constructor defined for this object." Should the ViewModelLocationProvider be using DI to get the View Model instance instead of Reflection?
The text was updated successfully, but these errors were encountered: