Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3806046
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:46:25+00:00 2026-05-19T14:46:25+00:00

Scenario App opens Checks to see if image for background exists in Isolated Storage

  • 0

Scenario

  1. App opens
  2. Checks to see if image for background exists in Isolated Storage
  3. If not, downloads from web, and saves it to Isolated Storage
  4. Loads the image from Isolated Storage and sets it as Background on a Panorama-control

Problem

The image is not loaded in GUI.. When I’m inspecting the byte-array received from isolated storage, it contains the same amount of bytes as was written initially, but the image doesn’t show up.

Here’s some test-code I’m currently using to try and 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 a loaded image from some other source
I’ve tried setting the sender as backgroundimage on the MainPanorama-control, and that works just fine. So the problem is in the loading from Isolated Storage.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T14:46:26+00:00Added an answer on May 19, 2026 at 2:46 pm

    Edit: Sounds like this has to be an issue with timing or with random access to the stream.

    Things you could try:

    1. Try loading the entire image into an in memory array – a MemoryStream – and then use that in the SetSource call

    2. Try removing the unused code – the .ImageOpened delegate and the img = new Image() call

    3. if those things don’t help then try checking the two streams at the byte level.

    For more info on 1, see How Do I Load an Image from Isolated Storage and Display it on the Device? – note that this is Microsoft’s support official sample and it loads the image into an in memory MemoryStream before using it in the on-screen Image.

    Microsoft’s code:

    // The image will be read from isolated storage into the following byte array
            byte [] data;
    
            // Read the entire image in one go into a byte array
            using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
            {
                // Open the file - error handling omitted for brevity
                                     // Note: If the image does not exist in isolated storage the following exception will be generated:
                // System.IO.IsolatedStorage.IsolatedStorageException was unhandled
                // Message=Operation not permitted on IsolatedStorageFileStream
                using (IsolatedStorageFileStream isfs = isf.OpenFile("WP7Logo.png", FileMode.Open, FileAccess.Read))
                {
                    // Allocate an array large enough for the entire file
                    data = new byte[isfs.Length];
    
                    // Read the entire file and then close it
                    isfs.Read(data, 0, data.Length);
                    isfs.Close();
                }
            }
    
            // Create memory stream and bitmap
            MemoryStream ms = new MemoryStream(data);
            BitmapImage bi = new BitmapImage();
    
            // Set bitmap source to memory stream
            bi.SetSource(ms);
    
            // Create an image UI element – Note: this could be declared in the XAML instead
            Image image = new Image();
    
            // Set size of image to bitmap size for this demonstration
            image.Height = bi.PixelHeight;
            image.Width = bi.PixelWidth;
    
            // Assign the bitmap image to the image’s source
            image.Source = bi;
    
            // Add the image to the grid in order to display the bit map
            ContentPanel.Children.Add(image);
    

    Please do report back on what fixed it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scenario: WCF client app, calling a web-service (JAVA) operation, wich requires a complex object
Is it possible to change the tile background image through code. The scenario is
Scenario: I build a simple web based app for mobile that needs to interact
I will try to explain a simple app scenario: My app goes right to
Scenario : You need to expose the same app on different screens - let's
Scenario I have a C# Win Forms App, where the Main Form contains a
Scenario I have two WCF Services combined in a single App.Config file. I can't
Here is the scenario: I'm writing an app that will watch for any changes
I have a scenario where I need a desktop console app to communicate with
This is my current scenario: I have checked in my grails app code +

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.