我正在尝试向带有典型 Windows Phone 共享图标的电话应用程序(8.1 和 UWP)的命令栏添加一个按钮。我如何向它添加这样的图标?
我还希望它能调出共享窗口,用户可以在其中选择不同的共享方式。它会在商店中共享指向我的应用程序的链接,就像从商店应用程序中一样。
最佳答案
1:Windows 10没有分享魅力,只能自己做图标了。这将使它:
<AppBarButton Label="Share" >
<AppBarButton.Icon>
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph=""/>
</AppBarButton.Icon>
</AppBarButton>
2:
在 UWP 中,我会使用共享契约(Contract)。 (基本上是 DataTransferManager 类……)
这是一个很好的文档: https://msdn.microsoft.com/en-us/library/windows/apps/xaml/mt243293.aspx
基本上:
连接事件(例如在页面的构造函数中......):
DataTransferManager.GetForCurrentView().DataRequested += MainPage_DataRequested;
显示 UWP 共享 UI(例如,在按钮的事件处理程序上......)
DataTransferManager.ShowShareUI();
做分享:
private void MainPage_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
{
args.Request.Data.SetWebLink(URI);
args.Request.Data.Properties.Title = "My new title";
args.Request.Data.Properties.Description = "description";
}
关于windows - 如何将共享按钮添加到 Windows 10 移动 UWP 应用程序的命令栏并向其共享功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33265938/