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 8138607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:32:47+00:00 2026-06-06T11:32:47+00:00

I have a GridView with elements containing a TextBlock and an Image. The TextBlock

  • 0

I have a GridView with elements containing a TextBlock and an Image. The TextBlock always populates fine, but the Image, once in a while, does not get loaded for one or two items. If I refresh the data source, the image correctly displays. I think the issue is with the timing (all data fetching is done asynchronously).
Here is the code that fetches the images from disk. All images are 140×140 pixels and are PNG files.

public async Task<List<BitmapImage>> getPhotos()
        {
            photos.Clear(); //clears list of photos

            IReadOnlyList<IStorageFile> files = (IReadOnlyList<IStorageFile>)await folderHierarchy.Last().GetFilesAsync(); //reads in all files from current working directory

            foreach (StorageFile currentFile in files) //for each file in that directory
            {
                if (currentFile.Name.EndsWith(".png")) //only handle png files
                {
                    photos.Add(await getBitmapImageAsync(currentFile)); //actually read in image from separate async method (bellow)
                }
            }

            return photos;
        }

        public async Task<BitmapImage> getBitmapImageAsync(StorageFile storageFile)
        {
            BitmapImage image = new BitmapImage();
            FileRandomAccessStream stream = (FileRandomAccessStream) await storageFile.OpenAsync(FileAccessMode.Read);
            image.SetSource(stream);

            return image;
        }

I run this method using: List tilePicturesArray = await dataFetcherClass.getPhotos();
The original photos List does not contain all of the photos. Something wrong is happening in that first block of code (above).
The next step is when I populate the Image and TextBox via in my List (GridViewCell is a class that I made to bind data in my GridView) The list of GridViewCell objects is what is binded to my GridView. I don’t believe that this is the issue.

for (int x = 0; x < tileTitlesArray.Count; x++) //this IS running inside of an async method
            {
                GridViewCell singleCell = new GridViewCell();

                singleCell.tileName = tileTitlesArray.ElementAt(x);
                singleCell.tileImage = tilePicturesArray.ElementAt(x);

                tileCells.Add(singleCell); //tileCells is the datasource for gridview
            }

What do you think would be causing the issue? I added a little refresh button which basically reruns the above loop (to repopulate the gridview datasource and tiles) but does not refetch the tilePicturesArray, so the binding is done using the same original List of BitmapImages (and the same tiles are still missing pictures)

  • 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-06-06T11:32:49+00:00Added an answer on June 6, 2026 at 11:32 am

    About 20 min after posting this, someone on the msdn forums answered my question. This issue has plagued my program since about a week ago, but I only really started to look into this infuriating issue in the past 3 days.

    HOW TO FIX: When populating your ListView or GridView data binding image from local disk, don’t use a Stream as the BitmapImage source – use the BitmapImage constructor with a Uri object pointing to your target image.

    Here’s how:

    `BitmapImage tempBitmap = new BitmapImage(new Uri(currentFile.Path));

    photos.Add(tempBitmap);`

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

Sidebar

Related Questions

I have a GridView that I need to dynamically add TemplateField elements to. My
is possible to have a separator between elements of a GridView? Thanks
I have a gridview that shows an image as part of one of its
I have a gridview in which there are two elements in each of its
I have a problem with Gridview sorting that is similar to others but I'm
i have a gridview layout, and all items are insert very fine, now if
I have a GridView where one column is bound to an object property containing
I have a gridview and I need to sort its elements when the user
I have a gridview with row selection which should set the page's elements value
I have the following gridview: I need to parse the first 8 elements of

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.