title: UWP Displaying images in GridView with DataTemplate
body: <h1>Context</h1>
  <p>I am attempting to display images from a directory inside the user's local pictures folder (e.g. C:\Users\Username\Pictures\The Folder) into a GridView.</p>
  <p>I am using a class for the image (this is the source for the GridView):</p>
  <pre><code>public class SpotlightImage
      {
          public string ID { get; set; }
  
          public string Name { get; set; }
  
          public string FileSource { get; set; }
      }
  </code></pre>
  <p>The XAML for the GridView is below:</p>
  <pre><code>&lt;GridView
              Padding=&quot;{StaticResource MediumLeftRightMargin}&quot;
              animations:Connected.ListItemElementName=&quot;thumbnailImage&quot;
              animations:Connected.ListItemKey=&quot;galleryAnimationKey&quot;
              IsItemClickEnabled=&quot;True&quot;
              ItemClick=&quot;ImagesGridView_ItemClick&quot;
              ItemsSource=&quot;{x:Bind Source, Mode=OneWay}&quot;
              RightTapped=&quot;ImagesGridView_RightTapped&quot;
              SelectionMode=&quot;None&quot;&gt;
              &lt;GridView.ItemTemplate&gt;
                  &lt;DataTemplate x:DataType=&quot;models:SpotlightImage&quot;&gt;
                      &lt;Image
                          x:Name=&quot;thumbnailImage&quot;
                          AutomationProperties.Name=&quot;{x:Bind Name}&quot;
                          Source=&quot;{x:Bind FileSource}&quot;
                          Style=&quot;{StaticResource ThumbnailImageStyle}&quot;
                          ToolTipService.ToolTip=&quot;{x:Bind Name}&quot; /&gt;
                  &lt;/DataTemplate&gt;
              &lt;/GridView.ItemTemplate&gt;
          &lt;/GridView&gt;
  </code></pre>
  <p>The C# for populating the source is below (I realise that it is most likely unnecessary to use the parallel foreach, however, I am using it for consistency with other code in the project):</p>
  <pre><code>private async void ImagesPage_OnLoaded(object sender, RoutedEventArgs e)
          {
              Source.Clear();
  
              storageFiles = new List&lt;Windows.Storage.StorageFile&gt;();
  
              List&lt;string&gt; SavedWallpapers = await RetrieveAllSavedWallpapers.Main(); //Retrieves image names
  
              galleryData = new List&lt;SpotlightImage&gt;();
  
              Parallel.ForEach(SavedWallpapers, spotlightFile =&gt;
              {
                  imgFileFunction(spotlightFile);
              });
  
              async void imgFileFunction(string spotlightFile)
              {
                  try
                  {
                      //StorageReferences.WallpaperSaveStorage is a StorageFolder variable for the images directory being accessed
                      Windows.Storage.StorageFile file = await StorageReferences.WallpaperSaveStorage.GetFileAsync(spotlightFile);
  
                      storageFiles.Add(file);
  
                      var img = new SpotlightImage()
                      {
                          ID = file.DisplayName,
                          FileSource = file.Path,
                          Name = file.DisplayName
                      };
  
                      galleryData.Add(img);
  
                      await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                      () =&gt;
                      {
                          Source.Add(img);
  
                          Debug.WriteLine(&quot;IMAGE ADDED: &quot; + img.Name);
                      }
                      );
                  }
                  catch (Exception ex)
                  {
                      Debug.WriteLine(&quot;MULTITHREADED ERROR: &quot; + ex.Message);
                  }
              }
          }
  </code></pre>
  <h1>The Problem</h1>
  <p>The GridView displays empty squares instead of images. The correct number of 'images' appear, but they are blank.</p>
  <h1>What I've tried</h1>
  <p>I have looked at similar issues on StackOverflow and tried the following:</p>
  <ol>
  <li>Using a UriSource instead of source (The same issue persists)</li>
  <li>Looked at the code (I have used the exact same code somewhere else in my project and it works there. The only difference is that a different folder is being accessed)</li>
  <li>Checked permissions (I have used this exact directory in previous code with no issue)</li>
  </ol>
  <h2>Notes:</h2>
  <p>My UWP application already has broadFileSystemAccess (It was necessary for my application's purpose).</p>
  <p>I have a FlipView which is accessing the same files and experiencing the exact same issue.</p>
  <p>I already have the exact same code running perfectly fine elsewhere in my project, the only difference is the folder being accessed. This led me to believe that the issue was permissions, but my application has broadFileSystemAccess. So this shouldn't be the issue (?)</p>
  <p>As you can probably tell, I am relatively new to UWP. So if there is some obvious permission issues or likewise, please go easy on me :)</p>