I'm using Prism 7.2.0.1422 in a WPF project and there is something I couldn't understand.
I'm trying to custom the ViewModelLocationProvider and specially with the method "SetDefaultViewModelFactory". So I override the method "ConfigureViewModelLocator" in App.xaml.cs and just to test I'm trying to raise an exception with:
protected override void ConfigureViewModelLocator()
{
base.ConfigureViewModelLocator();
ViewModelLocationProvider.SetDefaultViewModelFactory(viewModelType =>
{
throw new Exception("test ViewModelLocationProvider.SetDefaultViewModelFactory");
});
}
When I execute the code, the method "ConfigureViewModelLocator" is used so the ViewModelLocationProvider should be modified. But the "MainWindow" is opened normally with it view model "MainWindowViewModel". I use the same logic to raise en exception with the following code to be sure that I didn't make a mistake and this time the exception is thrown.
ViewModelLocationProvider.SetDefaultViewTypeToViewModelTypeResolver((viewType) =>
{
throw new Exception("test ViewModelLocationProvider.SetDefaultViewTypeToViewModelTypeResolver");
});
I also tested to custom the ViewModelLocationProvider with the method "SetDefaultViewModelFactory" in the sample project "09-ChangeConvention" available at https://github.com/PrismLibrary/Prism-Samples-Wpf. I noticed the same issue...
Maybe I'm doing something wrong or maybe the customization with "SetDefaultViewModelFactory" is ignore... Could someone help me? Thanks