title: How to Set Background Image from IsolatedStorage
body: <p>I am loading a <code>BitmapImage</code> from <code>IsolatedStorage</code> and would like to set the value to the background of MainPage. I am not sure how to properly do this?</p>
  
  <p>TombstoningHelper.cs</p>
  
  <pre><code>public async Task StorePhoto(Stream photoStream, string fileName)
      {
          // persist data into isolated storage
          StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);
  
          using (Stream current = await file.OpenStreamForWriteAsync())
          {
              await photoStream.CopyToAsync(current);
          }
      }
  
  public async Task&lt;BitmapImage&gt; RetrievePhoto(string fileName)
      {
          StorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync(fileName);
          Stream imageStream = await file.OpenStreamForReadAsync();
  
          //Check if file exists
  
          // display the file as image
          BitmapImage bi = new BitmapImage();
          bi.SetSource(imageStream);
  
          return bi;
      }
  </code></pre>
  
  <p>MainPage.xaml.cs</p>
  
  <pre><code>protected async override void OnNavigatedTo(NavigationEventArgs e)
      {
          //Set Page Theming
          ImageBrush ib = new ImageBrush();
          TombstoningHelper tsh = new TombstoningHelper();
  
          if (Settings.TransparentBackground.Value == null)
              ib.ImageSource = new BitmapImage(new Uri("/Assets/Graphics/" + Settings.Background.Value, UriKind.Relative)); //No Error
          else
              ib.ImageSource = tsh.RetrievePhoto(Constants.BackgroundImageName); //Error occurs here
  
          LayoutRoot.Background = ib;
  </code></pre>
  
  <p>I am getting an error above stating <code>Cannot implicitly convert type 'System.Threading.Tasks.Task&lt;System.Windows.Media.Imaging.BitmapImage&gt;' to 'System.Windows.Media.ImageSource</code>.</p>