共享图像只显示两个选项,Mail和Onenote

时间:2017-01-28 01:13:28

标签: c# uwp uwp-xaml

我正在尝试在本地共享图像,我正在检索它 enter image description here

但如果我打电话给

DataTransferManager.ShowShareUI();

我只有两个选择。但在照片应用程序中,当我分享照片时,我会看到所有兼容的应用程序,例如Instagram。但我的应用只有两个。 enter image description here

知道如何获得这样的所有选项吗? enter image description here

1 个答案:

答案 0 :(得分:2)

看起来你的代码只共享实际的位图:

req.data.SetBitmap(rasr)

在您安装的应用中,只有Mail和OneNote知道如何处理位图。这是相当常见的,许多共享目标将接受bitmap file但不接受位图本身。见How to share files

// Because we are making async calls in the DataRequested event handler,
// we need to get the deferral first.
DataRequestDeferral deferral = req.GetDeferral();  

// Make sure we always call Complete on the deferral.
try
{
    StorageFile logoFile = 
        await Package.Current.InstalledLocation.GetFileAsync("Assets\\beautiful_folder\\and_a_beautiful_file.jpg");
    List<IStorageItem> storageItems = new List<IStorageItem>();
    storageItems.Add(logoFile);
    req.Data.SetStorageItems(storageItems);       
}
finally
{
    deferral.Complete();
}