What's the difference between Resource and Content in a WPF application

Deadly 提交于 2020-12-28 20:38:05

问题


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

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

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

Any info?


回答1:


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

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.

Source: Resources in WPF.



来源:https://stackoverflow.com/questions/1935881/whats-the-difference-between-resource-and-content-in-a-wpf-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!