c# - 在 Microsoft Store 中共享 UWP App 的链接

标签 c# uwp windows-10 uwp-xaml

我在 Microsoft/Windows Store 中发布了一个 UWP 应用程序,我想在我的 uwp 应用程序中添加一个按钮“共享应用程序”。但我只想在 Microsoft Store 中共享我的 uwp 应用程序的链接。 我想和应用程序页面上 Microsoft Store 上的“共享”按钮做同样的事情。 Share Button in Microsoft Store

我该怎么做?

最佳答案

您需要使用 DataTransferManager 来显示标准的 Share 对话框和 DataRequest.Data 属性的 SetWebLink 方法链接到您的应用:

public sealed partial class MainPage : Page
{
    private DataTransferManager dataTransferManager;

    public MainPage()
    {
        this.InitializeComponent();

        dataTransferManager = DataTransferManager.GetForCurrentView();
        dataTransferManager.DataRequested += DataTransferManager_DataRequested;
    }

    private void DataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
    {
        DataRequest request = args.Request;

        request.Data.Properties.Title = "Share the App";
        request.Data.Properties.Description = "This App in Windows Store";
        request.Data.SetWebLink(new Uri("https://www.microsoft.com/en-us/store/p/netflix/9wzdncrfj3tj"));
    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        DataTransferManager.ShowShareUI();
    }
}

关于c# - 在 Microsoft Store 中共享 UWP App 的链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47442719/

相关文章:

C# 应用程序在关闭自定义表单时崩溃

c# - Razor 向隐藏字段发出错误的值

c# - 从互联网上的txt文件中获取文本

c# - Win2D 获取语义标签值

c# - XAML 设计器未加载

powershell - Chocolatey 在安装 openvpn 时返回错误

c# - 为什么我的 NamedPipeServerStream 不等待?

c# - 用于颜色提取 EMGUCV 的图像 HSV 的取值范围

c# - 更改通知气球大小

c# - 特定时间的后台任务