I am trying to store some soundclips which are tagged with Images chosen from ISO Storage through a PhotoChooserTask. I can successfully display the image in a standalone Image box but when I am setting the Imagebox source inside a listbox It does not shows the image. Currently what I am doing is something like this:
public ImageSource Image
{
get {
try
{
BitmapImage image;
if(Category == 11)
{
image = new BitmapImage(new Uri(this.ImageLocation));
}
return image;
}
catch (Exception)
{
return null;
}
}
I don't understand what is missing
BitmapImage
can't load image from Isolated Storage
. You need to read file image manually
BitmapImage bi = new BitmapImage();
using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream fileStream = myIsolatedStorage.OpenFile(this.ImageLocation, FileMode.Open, FileAccess.Read))
{
bi.SetSource(fileStream);
}
}
return bi;
Also, if this won't work, check CreateOptions
and set it to None