WPF 应用程序中的资源和内容有什么区别 [英] What's the difference between Resource and Content in a WPF application

查看:56
本文介绍了WPF 应用程序中的资源和内容有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近了解到嵌入式资源意味着将资产保存到外部 .resx 文件中.

I recently learned that Embedded Resource means that assets are saved to an external .resx file.

将资产设置为资源使它们简单地加入 .exe 文件.

Setting assets to Resource makes them join the .exe file simply.

现在,我对何时使用内容和资源感到困惑.

Now, I'm confused of when to use Content and Resource.

有任何信息吗?

推荐答案

Resource : 将资源嵌入到装配(或特定于文化的卫星组装)

Resource : Embeds resource into the assembly (or culture specific satellite assembly)

Content :这将资源保留为松散的文件并在编译时资源信息未嵌入组装.相反,它添加了自定义属性到程序集(AssemblyAssociatedContentFile) 其中记录存在和相对文件的位置.也有可能无需访问资源文件添加到项目中.然而,随着这种资源管理方式文件变得有点困难.然而,如果资源文件是使用动态生成的一些运行时信息.在这样一个情况下,资源文件将不会在编译时可用所以不能添加到项目中.

Content : this leaves resource as loose file and upon compilation this resource information is not embedded to assembly. Instead, it adds custom attribute to the assembly (AssemblyAssociatedContentFile) which records the existence and relative location of file. It is also possible to access the resource file without adding into the project. However, with this approach management of resource file becomes bit difficult. However, this approach is useful if resource file is generated dynamically using some runtime information. In such a case, resource file will not be available at compile time so can not be added to project.

来源:WPF 中的资源.

这篇关于WPF 应用程序中的资源和内容有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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