WPF Prism Request Navigate activation error

元气小坏坏 提交于 2019-12-23 01:37:12

问题


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)

Any ideas what i might be doing wrong?


回答1:


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
{ ... }


来源:https://stackoverflow.com/questions/33301926/wpf-prism-request-navigate-activation-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!