简体   繁体   中英

Using images from different projects inside a solution

I'm currently in the process of cleaning up my application and reordering things so they can be more easily put in different Portable Library Classes and be reused on different target platforms. One question I couldn't find an answer to is how to link to images residing in other projects within a solution.

For example: I have a WP7.1 project and the WMAppManifest.xml contains relative path to two images. Namely IconPath and BackgroundImageURI. So the obvious question is: How do I link to them in XML and how do I link to them programmatically when using the System.Uri class?

Your help is very much appreciated.

You could add the images as resources in your portable class library. They should not be added as images, though, but as strings. Excerpt from MSDN documentation (.NET Framework 4.5):

The exclusion of other ResourceManager members from the Portable Class Library means that serialized objects, non-string data, and images cannot be retrieved from a resource file. You may be able to work around this limitation by storing object data in string form. For example, you can store numeric values in a resource file by converting them to strings, and you can retrieve them and then convert them back to numbers by using the numeric data type's Parse or TryParse method. You can convert images or other binary data to a string representation by calling the Convert.ToBase64String method, and restore them to a byte array by calling the Convert.FromBase64String method.

You can find more information on how to access resources from your portable class library here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM