WPF Prism 请求导航激活错误 [英] WPF Prism Request Navigate activation error

查看:73
本文介绍了WPF Prism 请求导航激活错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

参考 StockTraderRI,我在 shell 中创建了一个弹出区域

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 是 OrderDetailsModule 中的一个视图.此时我收到以下错误

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"

堆栈跟踪如下所示

 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?

推荐答案

您必须为导航注册对象.如果您使用的是 Prism 6,则必须使用 Container.RegisterTypeForNavigation();

You must register your objects for navigation. If you are using Prism 6 you must use Container.RegisterTypeForNavigation<OrderDetailsView>();

如果使用 v5 或更低版本,则必须使用 container.RegisterType(typeof(object), typeof(OrderDetailsView), "OrderDetailsView");

If using v5 or less you must use container.RegisterType(typeof(object), typeof(OrderDetailsView), "OrderDetailsView");

如果使用 MEF,您必须在导出属性中提供视图名称:

If using MEF, you must provide the view name in the Export Attribute:

[Export("OrderDetailsView")]
public class OrderDetailsView : UserControl
{ ... }

这篇关于WPF Prism 请求导航激活错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆