PRISM 4 - RegisterViewWithRegion & Custom Export Attributes
|
I am using Prism 4 with MEF Extensions and the MVVM pattern. During initialization in a module I call RegisterViewWithRegion(RegionNames.MyRegion, typeof(MyView)) which works perfectly when the view is constructed like this:
The view gets registered and everything is fine. As soon as I change the Export to a Custom Export Attribute the view can't be found anymore, although it is still in the container. This Custom Export Attribute is taken from the Stock Trader RI:
and the interface is
By changing the Export Attribute to
when calling RegisterViewWithRegion it throws an error: Activation error occured while trying to get instance of type MyView, key "" Any advice? I was looking at this part of code the whole day without finding a solution. |
|||||
|
|
Another day, another way... I will try to answer my question even though I have only limited knowledge about PRISM. In other words: I'm still learning. The Custom Export Attribute taken from the Stock Trade RI is used by the
But I think when using ViewInjection and Prism Navigation it is better to just use the default [Export] attribute, then everything works smoothly. |
|||
|
Are you configuring the aggregate catalog in your MEF bootstrapper? If so, are you adding the assembly that contains your ViewExportAttribute and AutoPopulateExportedViewsBehavior classes? I believe this happens in the StockTraderRI's bootstrapper with this line:
The StockTraderRICommands class is in the same assembly as the ViewExportAttribute and AutoPopulateExportedViewsBehavior classes. |
|||||
|
|
The custom export attribute passes As far as the activation error you'll need to look at the exception in more detail. The root cause is probably there somewhere, perhaps buried under an InnerException. |
|||
|
I encountered exactly the same problem and it was a hard one for a MEF/PRISM beginner. okieh describes the problem very well, I just want to post an alternative solution, coming from theStocktraderUI sample application: The solution works (/seems to work) if you want View discovery without any form of config file, etc. where you have to register your views. 1. Modify the
The [Export] attribute is added and the base constructor is now called with 2. Modify
The That's basically it. You can use the This way, you don't need additional interfaces for your views and can still discover everything without hardcoded registration. I hope it helps and let me know, if I missed any drawbacks of my solution. http://stackoverflow.com/questions/6271167/prism-4-registerviewwithregion-custom-export-attributes |
PRISM 4 - RegisterViewWithRegion & Custom Export Attributes的更多相关文章
- [转]How do you create a custom AuthorizeAttribute in ASP.NET Core?
问: I'm trying to make a custom authorization attribute in ASP.NET Core. In previous versions it was ...
- jquery 使用attr() 函数对复选框无效的原因,javascript那些事儿——properties和attributes
复选框是网站开发的时候经常用到的网页标签之一,常见的在页面上对复选框的操作包括取值和修改复选框的状态.在jquery中,常见的操作标签的值得函数为attr,然而在操作复选框的时候,通常采用的却是pro ...
- Advanced Pricing - How to source Pricing Attributes using QP_CUSTOM_SOURCE.Get_Custom_Attribute_Valu
详细内容需要参考文档:Oracle 11i Advanced Pricing-Don't Customize, Extend! utl:http://blog.csdn.net/cai_xingyun ...
- [翻译]NUnit---Property and Random Attributes(十四)
小记:由于工作琐碎,没得心情翻译而且也在看<CLR vis C#>,所以断更了差不多5个月,现在继续翻译,保证会翻译完成,不会虎头蛇尾. 另:NUnit已经更新到2.6.3版本,虽然正在开 ...
- Collection View Programming Guide for iOS---(七)---Custom Layouts: A Worked Example
Custom Layouts: A Worked Example Creating a custom collection view layout is simple with straightfor ...
- Platform Invoke
PInvoke 允许managed code 来调用在DLL中实施的unmanged function. Platform invoke relies on metadata to locate ex ...
- configure.ac
# # Copyright (C) - Tobias Brunner # Copyright (C) - Andreas Steffen # Copyright (C) - Martin Willi ...
- CentOS7.2非HA分布式部署Openstack Pike版 (实验)
部署环境 一.组网拓扑 二.设备配置 笔记本:联想L440处理器:i3-4000M 2.40GHz内存:12G虚拟机软件:VMware® Workstation 12 Pro(12.5.2 build ...
- 所有selenium相关的库
通过爬虫 获取 官方文档库 如果想获取 相应的库 修改对应配置即可 代码如下 from urllib.parse import urljoin import requests from lxml im ...
随机推荐
- kernel module insmod错误
kernel模块配置 Enable loadable module support 打开可加载模块支持,如果打开它则必须通过"make modules_install"把内核模块安 ...
- Jdk1.8的安装(Linux和windows)
1.1 JDK1.8下载地址 JDK下载:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151. ...
- primer看完了
放假这将近十天吧,终于把C++ Primer中文版第五版大致看完了,然而第四部分(高级主题)还是没有看,感觉那是需要有足够的项目经验再看. 另外,看一遍肯定不够,忘得也会很快,我十分确认今后还会很多次 ...
- Spring相关概念
DIP: Dependency Inversion Principle.翻译过来是依赖反转原则,也叫依赖倒置原则. 依赖倒置原则是设计模式几个重要原则之一.具体定义就是,底层模块依赖高层模块定义的接口 ...
- 对比MySQL,你究竟在什么时候更需要MongoDB(转载)
你期望一个更高的写负载 万美元的交易. 不可靠环境保证高可用性 设置副本集(主-从服务器设置)不仅方便而且很快,此外,使用MongoDB还可以快速.安全及自动化的实现节点(或数据中心)故障转移. 未来 ...
- C++ 编码导致编译错误
记录一个问题 平时经常用Notepad++写C++,然后g++编译 最近出现一个莫名其妙的问题 原来是编译时遇到了非法字符 用Notepad++一看,原来文件的编码出现的变化 不是UTF-8或者其他对 ...
- linux 查找某文件所在路径
find 路径 -name 文件名 例如:find / -name logo_web.png 查找/路径下logo_web.png文件路径 如果为非root账号可用 sudo find / -nam ...
- @AutoConfigureBefore
@AutoConfigureBefore(Xxx.class)此注解用在类名上,标识在加载Xxx类前加载该配置类
- spring容器BeanFactory简单例子
在Spring中,那些组成你应用程序的主体及由Spring Ioc容器所管理的对象,都被称之为bean.简单来讲,bean就是Spring容器的初始化.配置及管理的对象.除此之外,bean就与应用程序 ...
- QTCreator:QSS语法高亮(QSS Syntax highlight)
由于QSS几乎等同CSS[1]语法,所以我们设置有 QT 语法高亮: Qtcreator QSS syntax highlight setting: Qt Creator QSS 语法交互设置:QTC ...