| We can pre-use the resources, slices, music, etc. in the program into the project, package it into the XAP document, and call from it when needed. Let's talk about the concrete implementation method. The first step is to save the data in the project. 1, right click on the project name-add-new folder (English version of the translation), the folder name in the image as an example, the need to drag the picture in, of course, you can not build, directly drag the picture to the project record, 2, select the picture just dragged in, Look at the bottom right corner of the Properties tab, if not, right-click the picture, select Properties. Build Action Select Resource. The second step, the program call.
System.IO.Stream src = application.getresourcestream (The new Uri ("/ph Oneapp4;component/image/a.png ", urikind.relative)).
Stream; |
Key in the format of the URI, PHONEAPP4 is the project name, component is the fixed path, image/a.jpg is the relative path of the picture resource, gets the stream , in the official Microsoft example, use the following method to convert to a picture: BitmapImage bi = new BitmapImage (); Bi. SetSource (SRC); Image img = new image (); Img. Source = bi; ----------------------------------------------------------------------------------------------------------- ------------ |