title: Windows Phone 8.1 Share Contract
body: <p>I wrote a <strong>Windows Phone 8.1 (WINRT) App</strong>. I am trying to share an <strong>image</strong> from my app which is in <strong>LocalStorage</strong> of the app. I am using <strong>Windows Phone 8.1 Share Contract.</strong></p>
  
  <pre><code>private async void OnShareDataRequested(DataTransferManager sender, DataRequestedEventArgs _dataRequestedEventArgs)
  {
      _dataRequestedEventArgs.Request.GetDeferral();
      List&lt;StorageFile&gt; ListObject = new List&lt;StorageFile&gt;();
      Uri UriObject = new Uri(FileLocation,UriKind.RelativeOrAbsolute);
  
      _dataRequestedEventArgs.Request.Data.Properties.Title = "Dr. App";
      _dataRequestedEventArgs.Request.Data.Properties.Description = "Photo from my Dr. App Album.";
  
  
      StorageFolder StorageFolderObject;
      StorageFile StorageFileObject;
          try
          {
  
              StorageFolderObject = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFolderAsync(LocalCache);
              StorageFileObject = await StorageFolderObject.GetFileAsync(FileNameSaved);
  
              _dataRequestedEventArgs.Request.Data.Properties.Thumbnail = RandomAccessStreamReference.CreateFromFile(StorageFileObject);
              _dataRequestedEventArgs.Request.Data.SetBitmap(RandomAccessStreamReference.CreateFromFile(StorageFileObject));
  
  
              ListObject.Add(StorageFileObject);
              _dataRequestedEventArgs.Request.Data.SetStorageItems(ListObject);
          }
          catch(Exception ex_)
          {
  
          }
          finally
          {
              _dataRequestedEventArgs.Request.GetDeferral().Complete();
  
          }
  
  
  }
  
  protected override void OnNavigatedFrom(NavigationEventArgs e)
  {
      DataTransferManager.GetForCurrentView().DataRequested -= OnShareDataRequested;
      base.OnNavigatedFrom(e);
  }
  
  protected override void OnNavigatedTo(NavigationEventArgs e)
  {
      DataTransferManager.GetForCurrentView().DataRequested += OnShareDataRequested;
      base.OnNavigatedTo(e);
  }
  private void Button_Click(object sender, RoutedEventArgs e)
  {
      DataTransferManager.ShowShareUI();
  }
  </code></pre>
  
  <blockquote>
    <p>I am getting PREPARING CONTENT TO SHARE and then it vanishes in a second. ShareUI doesnt open.</p>
  </blockquote>