Question

I have taken over a WP7 project from another developer, it is my first experience of WP7 (although far from my first use of .NET and/or XAML).

I have just spent a fair bit of time shouting at an image for not rendering the way I expected (aka not rendering). I was setting it's source property in code behind.

I have finally discovered that because this particular image (the others rendered fine) was set as "Build Action = Resource" I had to reference it in a different way. Why on earth did it not exception, but that is not the question!

Can someone please explain the differences between "Build Action = Resource" and "Build Action = Content" with relation to Images. Please be specific, such as how does it effect performance (and why!) etc.

Was it helpful?

Solution

The difference is the way that the image is built into the application's package (XAP). If it is specified as "Resource", then it is compiled into the application DLL. If it is specified as "Content", then it is included as part of the XAP, but sits outside of the DLL.

The performance implications are if you include it as a Resource, the application will take longer to load as it will need to deal with the embedded image as well. However, when it comes time to access that image, it will be faster since it has basically been loaded as a resource already.

In general, you should try to set images as Content unless you really need the quicker access.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top