1. Mohammad Ghazanfar Khan's Avatar
    I want to share an image in my windows phone 8.1 application using DataTransferManager.
    For this I use my windows 8.1 app code for sharing using DataTransfer which works fine on Windows 8.1 but it doesnt work on WP8.1.

    Here is my approach, I am converting my canvas into an image using RenderBitmap class then creating a RandomAccessStream of the bitmap to use in SetBitmap method.


    protected override void OnNavigatedTo(NavigationEventArgs e)
    DataTransferManager.GetForCurrentView().DataRequested+= MainPage_DataRequested;

    private async void MainPage_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
    var deferral = args.Request.GetDeferral();
    var bitmap = new RenderTargetBitmap();
    await bitmap.RenderAsync(canvas);

    // 1. Get the pixels
    IBuffer pixelBuffer = await bitmap.GetPixelsAsync();
    byte[] pixels = pixelBuffer.ToArray();

    // 2. Write the pixels to a InMemoryRandomAccessStream
    var stream = new InMemoryRandomAccessStream();
    var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.BmpEncoderId, stream);

    encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Straight, (uint)bitmap.PixelWidth, (uint)bitmap.PixelHeight, 96, 96,

    await encoder.FlushAsync();

    // 3. Share it
    args.Request.Data.Properties.Description = "description";
    args.Request.Data.Properties.Title = "title";

    This does not give any error but the image is not seen in the sharing apps like Messaging,OneNote etc.This code works fine in windows 8.1 app.Please need help stuck here for a long time.
    07-21-2014 04:17 PM
  2. Laura Knotek's Avatar
    Hi and welcome to WPCentral.

    I've moved your thread to the Developers Corner forum, since other developers will be able to assist you with coding better than regular users.
    07-21-2014 11:49 PM
  3. Expression2's Avatar
    MSDN says this class (DataTransferManager) works only in native apps. Check the documentation.
    07-24-2014 02:47 AM
  4. Vitor Salvatore Pierce's Avatar
    MSDN says this class (DataTransferManager) works only in native apps. Check the documentation.
    "Windows Phone 8
    This API is supported in native apps only."
    Said 8.0 and not 8.1.
    07-26-2014 05:05 AM

Similar Threads

  1. How do you use your 930?
    By AirSlab in forum Windows Phones
    Replies: 8
    Last Post: 07-22-2014, 06:33 PM
  2. Is possible to unlock my phone from my carrier?
    By WP_290 in forum Ask a Question
    Replies: 4
    Last Post: 07-22-2014, 12:28 PM
  3. What to use $20 Credit on?
    By mmbond in forum Windows Phones
    Replies: 8
    Last Post: 07-21-2014, 08:01 PM
  4. I need a similar app to AirSync
    By ULOP3Z in forum Other Operating Systems
    Replies: 0
    Last Post: 07-21-2014, 03:46 PM
  5. Modern Combat 5 hitting Windows and Windows Phone this Thursday
    By WindowsCentral.com in forum Windows Central News Discussion & Contests
    Replies: 0
    Last Post: 07-21-2014, 03:11 PM