c# - 共享图像仅显示两个选项,Mail 和 Onenote

标签 c# uwp uwp-xaml

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

但是如果我打电话

DataTransferManager.ShowShareUI();

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

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

最佳答案

看起来您的代码仅共享实际的位图:

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();
}

关于c# - 共享图像仅显示两个选项,Mail 和 Onenote,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41905429/

相关文章:

c# - 添加到选定文本操作菜单

c# - 在 ListViewItem UWP C# 中点击图像

c# - 如何像 Split View Pane 一样转换 UWP 导航 View Pane

c# - 根据 xaml 中的文本框禁用/启用按钮

c# - last_insert_id ? C#、SQL Server 和 NHibernate

c# - 幻灯片壁纸 Windows 7

c# - 是否可以访问本地目录中的文件? (通用Windows平台)

xaml - UWP 使用来自不同项目的页面

c# - 将数组初始化为动态大小 - C#

UWP DevCenter 无法识别所有语言