简体   繁体   English

管理棱镜资源的最佳方法

[英]Best way to manage prism resources

I have aa WPF prism desktop app with a few modules. 我有一个带有几个模块的WPF棱镜桌面应用程序。 I've put all the common images in a resources project and referenced it in all modules (it sorts of break modularity). 我已经将所有常见的图像放入资源项目中,并在所有模块中进行了引用(这是一些突破性的模块化)。 Is this the right way of doing it or having a module specific resources would be better (this will increase duplication though). 这是正确的做法还是拥有特定模块的资源会更好(尽管这样做会增加重复)。

All thoughts appreciated. 所有想法表示赞赏。

I use a library called Commons.Styling which contains all common aspects of the applications appearance like WPF styles, color and brush repositories, fonts and all sorts of common images and icons. 我使用一个名为Commons.Styling的库,其中包含应用程序外观的所有常见方面,例如WPF样式,颜色和笔刷存储库,字体以及各种常见的图像和图标。 It doesn't break modularity by any means, as you can still use internal resources in the other modules. 它不会以任何方式破坏模块化,因为您仍然可以在其他模块中使用内部资源。 Where to draw the line between the common and the module specific part has to be decided by you, of course. 当然,必须在公共部分和模块特定部分之间划清界限。 It is always a matter of personal style and circumstances (ie is the application already shipped, is it easier to exchange the module library rather than updating the common libraries on a customer machine, etc...). 这始终是个人风格和情况的问题(即,应用程序是否已经发货,是否更容易交换模块库而不是更新客户计算机上的公共库等)。

Long story short: Having a central styling project which also contains common image resources makes total sense. 长话短说:拥有一个也包含通用图像资源的中央样式项目完全有意义。 Nonetheless you should place module specific resources inside the module itself. 但是,您应该将模块特定的资源放置在模块本身内。

And just as an inspiration, here is my styling project structure: 作为启发,这是我的样式项目结构:

造型项目

The files Assets.xaml and Icons.xaml are resource dictionaries for images and icons only, which I merge into the central resource dictionary, called IncaDesign.xaml , in this particular case. 文件Assets.xamlIcons.xaml是图像和图标的资源字典,在这种情况下,我将它们合并到名为IncaDesign.xaml的中央资源字典中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM