Prism does not call the correct contructor #2803
-
Hi together, I would like to inspire my colleagues to use Prism.DryIoc for WPF. I have been asked to integrate Prism into an existing product in order to demonstrate prisms power. That is, the class design of this project already exists and cannot be easily changed. It would be great for me if you could spare a moment. Problem description: Example code: ============================================================= // This is my registered type
public SampleType(AnyType concreteType) ============================================================= // The implementation of prism in App class
} Thanks very much for your answer |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I got the following answer from Dan Siegel This is expected behavior. Prism ensures that the DI Container will automatically resolve any concrete type. It must function this way because of Prism’s ViewModelLocator which will resolve your ViewModel (a concrete type) automatically despite it not being registered with the container. |
Beta Was this translation helpful? Give feedback.
I got the following answer from Dan Siegel
This is expected behavior. Prism ensures that the DI Container will automatically resolve any concrete type. It must function this way because of Prism’s ViewModelLocator which will resolve your ViewModel (a concrete type) automatically despite it not being registered with the container.
Note that it is best practice to only have a single constructor, and that DI Containers will always default to a constructor with parameters over one without. If you were injecting an interface instead of a concrete type there then it would fallback to the default constructor if the interface wasn’t registered.