Reputation: 1069
in my WP7 application I have a listbox containing an image. I include several images within my application, but if an image is not found it should be retrieved from internet and then of course be stored in Isolated Storage. Now i have 1-2 questions: 1) On initial application start, should I copy all images into IsolatedStorage so that Isolated Storage contains all images (and therefore the images from images-folder of application are availabe twice: In application image directory and in isolated storage)? 2) Is it possible within the listbox to display images in one case from IsoloatedStorage and in the other from application file directory?
many thanks!
P.S. Code examples are welcome, especially in vb.net.
Upvotes: 2
Views: 230
Reputation: 21956
1 - No. Why waste time and storage?
2 - Possible solution - write a class that implements IValueConverter. In your Convert method, if the value is Uri with IsAbsoluteUri=true and Scheme="isostore", you read the file from isolated store, and return a BitmapImage, as described here. Otherwise, you just return unconverted value from your Convert method. And, you specify your converter in the binding.
Sorry I don't have code examples to share.
P.S. For your task, I'd recommend a 3-rd party lib called "Kawagoe Toolkit". The only drawback is the license that obliges you to mention them in your about page. If using Kawagoe, you could just define a property "imageSource" returning object, and return either Uri for images from resources/XAP, or delay loaded ImageSource object obtained from Kawagoe's ImageCache.Default.Get() method, which will eventually load itself from either isolated store of the Internets. They already have the downloading and caching code you need.
Upvotes: 1
Reputation: 1922
Upvotes: 0