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. How do I add such an icon to it?
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. This would make it:
<AppBarButton Label="Share" >
<AppBarButton.Icon>
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph=""/>
</AppBarButton.Icon>
</AppBarButton>
2:
In UWP I would use Share contract. (Basically the DataTransferManager class…)
Here is a good documentation for that: https://msdn.microsoft.com/en-us/library/windows/apps/xaml/mt243293.aspx
Basically:
Hook up the event (e.g. in your page’s constructor..):
DataTransferManager.GetForCurrentView().DataRequested += MainPage_DataRequested;
Show the UWP share UI (e.g. on the button’s event handler..)
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";
}