其他测试项目时没有问题,但是有些项目有时候导航一直报错误!
Referring the StockTraderRI, I created a popup region in my shell
infBehaviors:RegionPopupBehaviors.CreatePopupRegionWithName="{x:Static inf:RegionNames.SecondaryRegion}"
In the module I am trying to load the view to the popup
_regionManager.RequestNavigate(RegionNames.SecondaryRegion, new Uri("/OrderDetailsView", UriKind.Relative));
OrderDetailsView is a view within OrderDetailsModule. At this point I am getting the below error
Activation error occurred while trying to get instance of type Object, key "OrderDetailsView"
Stack trace looks like below
at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key) in c:\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs:line 53 at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService](String key) in c:\Projects\CommonServiceLocator\main\Microsoft.Practices.ServiceLocation\ServiceLocatorImplBase.cs:line 103 at Prism.Regions.RegionNavigationContentLoader.CreateNewRegionItem(String candidateTargetContract)
问题解决:
You must register your objects for navigation. If you are using Prism 6 you must use
Container.RegisterTypeForNavigation<OrderDetailsView>();
If using v5 or less you must use :
container.RegisterType(typeof(object), typeof(OrderDetailsView), "OrderDetailsView");
EDIT: If using MEF, you must provide the view name in the Export Attribute:
[Export("OrderDetailsView")] public class OrderDetailsView : UserControl { ... }
问题解决!
http://*.com/questions/33301926/wpf-prism-request-navigate-activation-error
https://github.com/PrismLibrary/Prism/blob/master/Documentation/WPF/60-Navigation.md#basic-region-navigation