简体   繁体   中英

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. But I want only share the link of my uwp app in Microsoft Store. I want to do the same as the "Share" button on the Microsoft Store on the application page. 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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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