Scenario
- Open application
- Checks if image for background exists in isolated storage
- If not, download from the Internet and save it in isolated storage
- Loads an image from isolated storage and sets it as a background in panorama control mode
Problem
The image does not load into the graphical interface. When I check the byte array received from the isolated storage, it contains the same number of bytes as at the beginning, but the image is not displayed.
Here is some test code that I am currently using to try to figure out the problem:
using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication()) { if (!appStorage.FileExists(@"default.jpg")) { BitmapImage bmp = sender as BitmapImage; byte[] bytes = bmp.ConvertToBytes(); using (var inputfile = appStorage.CreateFile(@"default.jpg")) { inputfile.Write(bytes, 0, bytes.Length); } } using (var isfs = appStorage.OpenFile(@"default.jpg", FileMode.OpenOrCreate, FileAccess.Read)) { BitmapImage bmp = new BitmapImage(); bmp.SetSource(isfs); MainPanorama.Background = new ImageBrush { Opacity = 0.4, Stretch = Stretch.None, ImageSource = bmp }; } }
Where sender is the downloaded image from another source. I tried to configure the sender as backgroundimage on MainPanorama-control, and this works fine. Therefore, the problem is loading from isolated storage.
Any ideas?
source share