Silverlight如何内嵌资源,适用于Windows Phone

Silverlight使用资源文件(例如图片和配置文件)有两种方式,第一种使用URL指向网络上的资源,第二种使用内嵌资源。但是在Silverlight for Windows Phone使用图片只能使用内嵌资源的方式,下面讲述在Silverlight下如何内嵌资源。

 

image

 

选择需要内嵌的资源,然后右键选择属性。

image

Build Action选择Content。Copy to Output Directory选择Do not copy。

 

 

 

image

重新编译生成xap文件。

 

image

把xap文件改名为zip文件。

 

image

解压zip文件,发现需要的资源文件已经拷贝到xap文件里面了。

 

下面是使用内嵌资源的代码。

private const string xmlFile = "Config/SilverRadio.xml";

XDocument xDoc = XDocument.Load(xmlFile);
posted @ 2010-08-16 06:32  Jake Lin  阅读(1430)  评论(4编辑  收藏  举报