在设计时如何在棱镜模块中使用资源字典? [英] How to use resource dictionary in prism modules at design time?

查看:112
本文介绍了在设计时如何在棱镜模块中使用资源字典?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Silverlight应用程序中使用棱镜框架,并在单独的XAP中使用多个模块.

I am using prism framework in a silverlight app with multiple modules in separate XAPs.

我在shell项目中定义了一个资源字典.在我的模块中,我可以很好地使用资源,但是由于模块是从外壳解耦的,直到它们在运行时加载,设计人员才不会显示或识别它们.

I have a resource dictionary defined in my in my shell project. In my modules I can use the resources fine, but since the modules are decoupled from the shell until they are loaded at runtime the designer does not show them or recognize them.

是否有一种方法可以使模块在设计时就知道我的资源,而无需在每个视图xaml中合并我的资源文件?

Is there a way to make the modules aware of my resources at design time without merging my resource file in every view xaml?

我的资源文件在一个普通"项目中.

My resource files are in a "common" project.

推荐答案

我发现有两种解决方案:

I have found there are a couple of solutions to this:

1)创建模块项目时,请将App.xaml留在项目中,而不要删除它并在其中实例化资源,就好像它是自己的应用程序一样(也可以向其中添加新的Application类该项目(如果您已将其删除).当您的模块加载到外壳中时,该文件将被忽略,因此它实际上仅在设计时有效.尽管如果您有很多模块,这可能在Visual Studio和Blend中很好用,但是内存占用可能会成为问题.

1) When you create a module project, leave the App.xaml in the project instead of deleting it and instantiate your resources in there just as if it were its own application by itself (you can also add a new Application class to the project if you have already deleted it). When your module is loaded into the shell that file will be ignored so it's essentially only valid during design time. This works well in visual studio and blend although if you have many modules, memory footprint may become a problem.

2)使用设计时间资源.有关在此处进行设置的一些信息:

2) Using design time resources. Some info about setting this up here: http://adamkinney.com/blog/2010/05/04/design-time-resources-in-expression-blend-4-rc/. This offers only blend support and your views will be stripped of all styles and formatting in visual studio. This was not ideal for me because I like working on certain aspects of the UI in visual studio. There also doesn't seem to be a documented way of manually setting up design time resources.

这篇关于在设计时如何在棱镜模块中使用资源字典?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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