WP7中图片设置成Content和Resource的区别

在WP7项目,图片资源文件的属性对话框Properties,在Build Action项有很多选项,但WP7中只支持:Content、Resource、none这三种。

设置为Content时会直接将图片文件打包到XAP文件中,就是说用ZIP查看器可以直接看到你的图片文件;

设置为Resource后,图片会编译到XAP的Dll文件内;

设置为none后,图片既不会直接打包在xap文件中,也不会嵌入xap中的dll内,编译过程会完全忽略该文件。

一般情况下,用Content更简单,能获得更好的效率。

MSDN的原文

Set Build Action to Content for Media

Media processing on Windows Phone is optimized to use files and network streams, but not in-memory streams. This means that any media files included in the application, such as sound effects, should have their Build Action set to Content and not Resource. When a media file is compiled as content, it is stored as a loose file alongside the application file (.XAP) and is not stored inside it. When a media file is compiled as a resource, you typically access it by retrieving a stream to the file, which can decrease performance. Also, when a media file compiled as content is played back, it is played directly. When a media file is compiled as a resource, the content is copied to a file on Windows Phone before playback, which decreases performance. The following illustration shows how to set the Build Action of a file in Visual Studio.

有关Build Action的相关内容,参考这里

 

你可能感兴趣的:(resource)