简体   繁体   English

在Microsoft Store中共享UWP App的链接

[英]Share Link of UWP App in Microsoft Store

I have an UWP app published in Microsoft/Windows Store, and I want add a button "Share app" in my uwp app. 我有一个在Microsoft / Windows Store中发布的UWP应用程序,我想在uwp应用程序中添加一个“共享应用程序”按钮。 But I want only share the link of my uwp app in Microsoft Store. 但我只想在Microsoft Store中共享uwp应用程序的链接。 I want to do the same as the "Share" button on the Microsoft Store on the application page. 我想做与应用程序页面上Microsoft Store上的“共享”按钮相同的操作。 Microsoft Store中的共享按钮

How do I do that? 我怎么做?

You need to use DataTransferManager to display a standard Share dialog and SetWebLink method of DataRequest.Data property to link to your app: 您需要使用DataTransferManager显示标准的“ 共享”对话框,并SetWebLink 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();
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM