Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

resources

wpf

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?

like image 237
Sergio Tapia Avatar asked Dec 20 '09 13:12

Sergio Tapia


1 Answers

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.

like image 75
Moayad Mardini Avatar answered Sep 21 '22 14:09

Moayad Mardini