plucked
plucked

Reputation: 511

Open Image from IsolatedStoreage?

I want to open an Image from the IsolatedStorage?

The image was downloaded before and correctly written (I checked that with the Isolated Storage Explorer).

When I try to open the Image with BitmapImage(uriInIsolatedStorage) and set that as source for a Silverlight Image Control it crashs when I listen to the image failed event.

The exception said "AG_E_NETWORK_ERROR"

Does anyone has an idea?

Uri imageSource = new Uri("/cover.jpg",  UriKind.Relative);
BitmapImage bi = new BitmapImage(imageSource);
bi.ImageFailed += new EventHandler<ExceptionRoutedEventArgs>(MainPage_ImageFailed);
bi.ImageOpened +=new EventHandler<RoutedEventArgs>(bi_ImageOpened);
imageCtrl.Source = bi;

Upvotes: 0

Views: 1186

Answers (1)

Heinrich Ulbricht
Heinrich Ulbricht

Reputation: 10372

Unfortunately you cannot load an image directly from isolated storage via URI. You have to open the file and do some more steps as described here or (a bit easier) here.

It boils down to:

  • creating an IsolatedStorageFileStream for your image
  • creating a BitmapImage from file data
  • setting BitmapImage as Image source

There is also an isostore: URI scheme but it doesn't work.

Upvotes: 3

Related Questions