我在 Microsoft/Windows Store 中发布了一个 UWP 应用程序,我想在我的 uwp 应用程序中添加一个按钮“共享应用程序”。但我只想在 Microsoft Store 中共享我的 uwp 应用程序的链接。 我想和应用程序页面上 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/