1
votes

is there a way for the Prism ViewModelLocator to autowire the views and viewmodels from different class library beside just the WPF project?

Currently my WPF MainWindow.xaml is in a Views folder in the WPF project and is auto wired to link with MainWindowViewModel in a ViewModels folder. The datacontext is wired and works fine.

My MainWindow view used other views(usercontrols) that's in a class library and the Prism ViewModelLocactor doesnt seem to auto wire the views and viewmodels. Is there a way for this to work? The datacontext is link if I manually inject the viewmodels, but once I comment the code and expect Prism to handle it, the datacontext is not wired.

1

1 Answers

1
votes

Yes. Either change the ViewModelLoctor convention to fit your needs, or use the ViewModelLocationProvider.Register method to specify which VM should be used for a view.

http://brianlagunas.com/getting-started-prisms-new-viewmodellocator/