简体   繁体   English

如何将分享按钮添加到Windows 10移动UWP应用程序的CommandBar并共享其功能?

[英]How to add Share button to the CommandBar of a Windows 10 Mobile UWP App and sharing capabilities to it?

  1. I'm trying to add a button to the command bar of a phone app (8.1 and UWP) with a typical Windows Phone share icon. 我正在尝试使用典型的Windows Phone共享图标向手机应用程序(8.1和UWP)的命令栏添加一个按钮。 How do I add such an icon to it? 如何添加这样的图标?

  2. I'd also like it to bring up the sharing window where the user can select the different ways of sharing something. 我也希望它能打开共享窗口,用户可以选择不同的共享方式。 It would share the link to my app in the store, like from the store app. 它将分享商店中我的应用程序的链接,例如从商店应用程序。

1: There is no share charm in Windows 10. What you can do is that you do the icon yourself. 1:Windows 10中没有共享魅力。您可以做的是自己做图标。 This would make it: 这将使它:

<AppBarButton Label="Share"  >
    <AppBarButton.Icon>
        <FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE72D;"/>
    </AppBarButton.Icon>
</AppBarButton>

2: 2:

In UWP I would use Share contract. 在UWP中,我会使用股份合约。 (Basically the DataTransferManager class…) (基本上是DataTransferManager类......)

Here is a good documentation for that: https://msdn.microsoft.com/en-us/library/windows/apps/xaml/mt243293.aspx 这是一个很好的文档: https//msdn.microsoft.com/en-us/library/windows/apps/xaml/mt243293.aspx

Basically: 基本上:

Hook up the event (eg in your page's constructor..): 连接事件(例如在页面的构造函数中......):

DataTransferManager.GetForCurrentView().DataRequested += MainPage_DataRequested;

Show the UWP share UI (eg on the button's event handler..) 显示UWP共享UI(例如,在按钮的事件处理程序上..)

DataTransferManager.ShowShareUI();

Do the sharing: 分享:

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";
}

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

相关问题 Windows UWP App移动后退按钮不起作用 - Windows UWP app mobile back button not working Windows 10 UWP混合移动应用程序的推送通知 - Push Notifications for Windows 10 UWP hybrid mobile app 在Windows Phone 8、8.1和10(移动版)上创建共享按钮 - Create a Share button on Windows Phone 8, 8.1 and 10 (Mobile) Windows 10 UWP MediaDeviceControl.Capabilities不支持亮度,对比度等功能 - Brightness, Contrast, etc capabilities not supported under Windows 10 UWP MediaDeviceControl.Capabilities 如何为我的应用程序按钮(UWP)评分 - How To Add Rate My App Button (UWP) 在UWP(适用于Windows-10的Windows Universal应用程序)的“移动”视图中看不到背景图像? - Background Image in not visible in Mobile view in UWP (Windows Universal app for Windows-10)? 如何共享/分发为Blackberry 10和Windows 8移动开发编译 - How to share/distribute compiled for Blackberry 10 and Windows 8 mobile development 如何要求 Windows 10 从 UWP 应用程序索引 USB 密钥? - How to require Windows 10 to index a USB key from a UWP app? 如何在Windows 10 UWP应用程序中播放(MIDI)声音? - How do you play a (MIDI) sound in a Windows 10 UWP App? 适用于Windows 8和Windows 10的Windows UWP应用 - Windows UWP app for Windows 8 and 10 both
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM