Skip to content

Prism does not call the correct contructor #2803

Discussion options

You must be logged in to vote

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.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Esterl-Christian
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
WPF
Labels
None yet
1 participant