I need to bind images located in isolated storage –
I found one answer here and it seems my situation
Binding image in Isolated Storage
But then this person has switched to the another solution and used ClientBin for image storage. My pictures will be different all the time.
Now I use images from the server, but I need to save them to the isolated storage and bind to the listBox
code in XAML:
Image Width="110" CacheMode="BitmapCache" Source="{Binding ThumbURL}"
code behind:
public string ThumbURL
{
get
{
return String.Format("http://localhost:3041/Pictures/thumbs/{0}.jpg", _ID);
}
set
{
this.OnThumbURLChanging(value);
this._ThumbURL = value;
this.OnThumbURLChanged();
this.OnPropertyChanged("ThumbURL");
}
}
Can anyone advice me of how to do it? I’ll be really, really grateful.
Please post some example of the code.
To download pictures from the web see this previous SO question – how-can-i-download-and-save-images-from-the-web.
The difference with binding an image in Isolated Storage is that you have to bind to a BitmapImage object which you initialise from your bound code object. I’ve renamed your property to “ThumbImage” from “ThumbURL” to show the difference.
So in XAML:
And in your bound object – assuming this picture doesn’t change – if it does you’ll have to raise the property changed event as appropriate. (code edited to deal with class serialization issue).
(Edited to add link to how to download image in the first place)