For a container to inject constructor parameters the object being initialized needs to be initialized from the container.
var myWindow = new MyWindow();
var myWindow = ServiceLocator.Current.GetInstance<mywindow>();
</mywindow>
Now the keyword in the latter example is allows elements to be injected... Because the way you actually have this laid out is not a recommended practice. You want the Window's constructor to actually have the view model injected so that the latter example I provided (or any other resolve) to create the view model.
Use something like this instead:
[ImportingConstructor]
public ReleaseManagementView(ReleaseManagementViewModel releaseManager)
{
InitializeComponent();
DataContext = releaseManager;
}
This example requires that the
ReleaseManagementViewModel
be registered with the container as well. If the constructor parameters cannot be found in the container and are not overridden, the resolution on the
ReleaseManagementView
will fail. If I tried to put this inside the XAML as you have even if everything is registered appropriately, it will still fail because nothing is directing the container to resolve that element.
That's why you get your error... It's not trying to resolve that view model through the container so there's no available constructor trying to do a simple
new()
.