title: x:Bind data not showing up for async / await loaded data set in UWP app
body: <p>In my project, I recently made a change in how I was loading data in my application (UWP app) and in the process it has broken data binding (what was previously showing up in the bound list is now showing up as empty) but I am not fully understanding why.  I have seen a bunch of posts here that discuss async data binding and I thought that I had followed everything fine.</p>
  
  <p>I had previously been loading a json file using <code>File.OpenRead()</code> but in order to fix a different issue I was running into, I changed it over to using the <code>StorageFile</code> stream.  Because I was now using <code>await StorageFile.CreateFileAsync()</code>, I saw that my <code>OnNavigatedTo()</code> was now running the next line of code before my object creation was completed.  So I tried to convert it over and make it await the async object, which works fine in terms of timing except my bindings no longer show the data (setting the breakpoint does show that the ObservableCollection has data).</p>
  
  <p>I think I boiled it down to just the relative code pieces here:</p>
  
  <p>MainPage.xaml:</p>
  
  <pre><code>&lt;ListView x:Name="lstAudioFX" ItemsSource="{x:Bind AudioFXModel.FXList}"&gt;
       &lt;ListView.ItemTemplate&gt;
            &lt;DataTemplate x:DataType="models:CheckBoxData"&gt;
                 &lt;StackPanel Orientation="Horizontal" HorizontalAlignment="Left"&gt;
                      &lt;CheckBox Content="{x:Bind Name}" IsChecked="{x:Bind Selected, Mode=TwoWay}"/&gt;
                 &lt;/StackPanel&gt;
            &lt;/DataTemplate&gt;
        &lt;/ListView.ItemTemplate&gt;
  &lt;/ListView&gt;
  </code></pre>
  
  <p>MainPage.xaml.cs:</p>
  
  <pre><code>public AudioFXViewModel AudioFXModel;
  
  protected async override void OnNavigatedTo(NavigationEventArgs e)
  {
      // Originally was just AudioFXViewModel.Create(
      AudioFXModel = await AudioFXViewModel.CreateAsync();
  
      // Breakpoint here was initially hitting before Create() finished prior to modifying to await / async
      if (AudioFXModel.NeedsProcessing)
      {
          ...
      }
  
      base.OnNavigatedTo(e);
  }
  </code></pre>
  
  <p>AudioFXViewModel.cs</p>
  
  <pre><code>public class CheckBoxData
  {
      public string Name { get; set; }
      public bool Selected { get; set; }
  }
  
  public class AudioFXViewModel : INotifyPropertyChanged
  {
      public event PropertyChangedEventHandler PropertyChanged;
      public void OnPropertyChanged([CallerMemberName] string propertyName = null)
      {
          this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(propertyName)));
      }
  
      private bool _fNeedsProcessing = false;
      public bool NeedsProcessing { get =&gt; _fNeedsProcessing; }
  
      private ObservableCollection&lt;CheckBoxData&gt; _FXList;
      public ObservableCollection&lt;CheckBoxData&gt; FXList { 
          get =&gt; this._FXList; 
  
          set
          {
              _FXList = value;
              this.OnPropertyChanged("FXList");
          } 
      }
  
      private AudioFXViewModel(){}
  
      // Originally public static AudioFXViewModel Create()
      public static async Task&lt;AudioFXViewModel&gt; CreateAsync()
      {
          AudioFXViewModel audioFXViewModel = new AudioFXViewModel();
  
          // Originally audioFXViewModel.LoadFXContent();
          await audioFXViewModel.LoadFXContentAsync();        
  
          return audioFXViewModel;
      }
  
      // Originally private void LoadFXContent()
      private async Task LoadFXContentAsync()
      {
          // Originally using File.OpenText()
          StorageFile jsonFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Data/Settings.json"));
  
          using (StreamReader sr = new StreamReader(await jsonFile.OpenStreamForReadAsync()))
          {
              var json = sr.ReadToEnd();
  
              // The relevant info here is that FXData has a serialized list (FXList) of applicable FX
              var data = JsonConvert.DeserializeObject&lt;FXData&gt;(json);
  
              ObservableCollection&lt;CheckBoxData&gt; FXs = new ObservableCollection&lt;CheckBoxData&gt;();
              foreach (string s in data.FXList)
              {
                  FXs.Add(new CheckBoxData() {Name = s, Selected = true });
              }
  
              FXList = new ObservableCollection&lt;CheckBoxData&gt;(FXs);
  
              _fNeedsProcessing = true;
          }
      }
  }
  </code></pre>
  
  <p>I hadn't previously needed to call the <code>OnPropertyChanged</code> when I set the ObservableCollection, but even that doesn't seem to make a difference.  If I remove the <code>await</code> from <code>AudioFXModel = await AudioFXViewModel.CreateAsync();</code>, then the data will bind / display fine, except I am back at my original issue where <code>NeedsProcessing</code> hasn't been set yet because it didn't wait.</p>
  
  <p>** UPDATE ** 
  So in doing some additional debugging here, it seems that the call to <code>GetFileFromApplicationUriAsync()</code> is what is causing the scenario to break</p>