Where is Silverlight’s Isolated Storage Image Support?
The example we wanted to use for the tutorial was putting an image into isolated storage and then displaying the image at a later time. For instance, we thought it would be cool if the user could browse to an image on their local computer, and then we could display it in a silverlight app. Currently, the only way to do that would be to actually upload the image to the webserver, and then reference it from there. But we thought it would be really cool if we could just copy the image to the isolated storage space and then display it - getting rid of the time and bandwidth consuming step of uploading the image. While we are able to put an image into the isolated storage space (isolated storage lets you put pretty much whatever you want into the 1MB of available space), we have had no success getting silverlight to read the image back out and display it on the screen.
Silverlight has two elements available for displaying images: Image and ImageBrush. Neither of these elements have the ability to read image data from a file stream, which is required for reading content from isolated storage.
|
We’d be perfectly happy if you could reference isolated storage using a special uri synax - something like
"ifs://myNewImage.jpg", where “ifs” stands for Isolated File Storage, but as far as we can tell, this isn’t supported.
We’re fully aware that isolated storage was added in 1.1 and is still alpha. That being said, this will be a feature we’ll look forward to having in future releases. Reading and writing images to isolated storage would also be a great feature when the browser’s caching mechanism is not quite doing what you want - you could store images and other content there by whatever rules you define. We still plan on putting up some tutorials on using isolated storage, but we thought we’d go ahead and post this rant before we create the tutorials.
We have a couple ideas on some ridiculously convoluted ways to make it work, but something that complicated isn’t worth using. If someone out there has some insight on this topic, please drop us a line.
Posted in Rants, Silverlight, All Tutorials by The Reddest |

September 24th, 2007 at 8:12 pm
MS definitely does need to let us do this!
For now, you might be interested to check out fluxify @ fluxtools.net… although we’re not storing images in isolated storage, we implemented the ability to view thumbnails of client-side images, albeit for a different purpose…
February 14th, 2008 at 12:03 pm
Wouldn’t it just be better to give Image the Image.FromStream support that standard System.Drawing.Image has in .NET rather than creating a faux protocol?
June 2nd, 2008 at 2:18 am
Hi,
You said that you were able to store an image into the isolated storage space. Can you please let me know how you did that.
Thanks
July 3rd, 2008 at 7:36 am
Hi,
Do u guys figured how to use isolated stored images ? Would be very helpful..
Thanks,
Gopi
July 30th, 2008 at 9:03 am
Gopinath>>
With the release of beta 2 it should be easy.
In this snippet of code I do almost the same thing. Note that it’s some custom things not needed for you, like PictureShell that is specific to the app where I use this.
PictureShell shell = this.DataContext as PictureShell;
Stream stream = shell.FileDialogFileInfo.OpenRead();
BitmapImage imageSource = new BitmapImage();
imageSource.SetSource(stream);
PreviewImage.Source = imageSource;
stream.Close();
stream.Dispose();
The only difference is that the PictureShell contains the FileDialogInfo so I open the stream from that instead of a file from IS. But I know you can get a stream from an Image in IS so I’m sure it can be done just changing the first steps where you retrive the stream.
Note: PreviewImage is an Image declared in XAML
Hope it helps anyone looking for how to load a local image into a Image element.
August 21st, 2008 at 9:32 am
I read your problem and i started building somthing. this works, but may not be the best suloution.
http://tagnard.net/2008/08/20/save-image-in-isolated-storage/
October 24th, 2008 at 6:20 am
To load an image from Isolated Storage, you can do this:
IsolatedStorageFile isStore = IsolatedStorageFile.GetUserStoreForApplication();
IsolatedStorageFileStream isolatedStorageFileStream = isStore.OpenFile(”example.jpg”, FileMode.Open); //assumption: example.jpg has already been saved to IsolatedStorage
bitmapImage = new BitmapImage(); bitmapImage.SetSource(isolatedStorageFileStream);
Image image = new Image();
image.Source = bitmapImage;
October 24th, 2008 at 9:27 am
Yup, we actually just wrote a post about that here - and it is great that Microsoft added that in to Silverlight 2.