Prism Sample 10 10-CustomRegistrations
作用同上节,这里是用修改注册的方式自定义View和ViewModel的关联。
protected override void ConfigureViewModelLocator() { base.ConfigureViewModelLocator(); // type / type //ViewModelLocationProvider.Register(typeof(MainWindow).ToString(), typeof(CustomViewModel)); // type / factory //ViewModelLocationProvider.Register(typeof(MainWindow).ToString(), () => Container.Resolve<CustomViewModel>()); // generic factory //ViewModelLocationProvider.Register<MainWindow>(() => Container.Resolve<CustomViewModel>()); // generic type ViewModelLocationProvider.Register<MainWindow, CustomViewModel>(); }