Hi,
Thanks for sharing this.
Prism’s ViewModelLocator class has an attached property, AutoWireViewModel that when set to true (as in your scenario) will try to locate the view model of the view, and then set the view’s data context to an instance of the view model. To locate the corresponding view model, the ViewModelLocationProvider first attempts to resolve the view model from any mappings that may have been registered by the Register method of the ViewModelLocationProvider class. If the view model cannot be resolved using this approach, for instance if the mapping wasn't created, the ViewModelLocationProvider falls back to a convention-based approach to resolve the correct view model type. This convention assumes that view models are in the same assembly as the view types, that view models are in a .ViewModels child namespace, that views are in a .Views child namespace, and that view model names correspond with view names and end with "ViewModel."
If you don't have any mapping registered, it might be possible that this is failing because your ViewModel is not following the default naming convention (It should be named FluentRibbonViewViewModel instead of FluentRibbonViewModel)
If your View Models are in different assembly, then you will have to override the logic of the ViewModelLocator.SetDefaultViewTypeToViewModelTypeResolve.
I hope you find this helpful.
Thanks,
Ez
http://blogs.southworks.net
Thanks for sharing this.
Prism’s ViewModelLocator class has an attached property, AutoWireViewModel that when set to true (as in your scenario) will try to locate the view model of the view, and then set the view’s data context to an instance of the view model. To locate the corresponding view model, the ViewModelLocationProvider first attempts to resolve the view model from any mappings that may have been registered by the Register method of the ViewModelLocationProvider class. If the view model cannot be resolved using this approach, for instance if the mapping wasn't created, the ViewModelLocationProvider falls back to a convention-based approach to resolve the correct view model type. This convention assumes that view models are in the same assembly as the view types, that view models are in a .ViewModels child namespace, that views are in a .Views child namespace, and that view model names correspond with view names and end with "ViewModel."
If you don't have any mapping registered, it might be possible that this is failing because your ViewModel is not following the default naming convention (It should be named FluentRibbonViewViewModel instead of FluentRibbonViewModel)
If your View Models are in different assembly, then you will have to override the logic of the ViewModelLocator.SetDefaultViewTypeToViewModelTypeResolve.
I hope you find this helpful.
Thanks,
Ez
http://blogs.southworks.net