问题
I am developing an app and i am trying to share my app, in Windows Phone 8 Siverlight and Windows Phone 8.1 Silverlight, i used these codes:
ShareLinkTask shareLinkTask = new ShareLinkTask();
shareLinkTask.Title = "Code Samples";
shareLinkTask.LinkUri = new Uri("http://code.msdn.com/wpapps", UriKind.Absolute);
shareLinkTask.Message = "Here are some great code samples for Windows Phone.";
shareLinkTask.Show()
But in Windows Phone 8.1 using Windows Runtime, when i use these codes, it reports an error that this namespace doesn't exist. So, what namespace can replace ShareLinkTask on Windows Phone 8.1 using Windows Runtime ? Sorry for my bad english. Thank you !
回答1:
In Windows Phone 8.1, You can share link using DataTransferManager(namespace:Windows.ApplicationModel.DataTransfer).
Here is code:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
DataTransferManager dtManager = DataTransferManager.GetForCurrentView();
dtManager.DataRequested += dtManager_DataRequested;
}
private async void dtManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs e)
{
e.Request.Data.Properties.Title = "Code Samples";
e.Request.Data.Properties.Description = "Here are some great code samples for Windows Phone.";
e.Request.Data.SetWebLink(new Uri("http://code.msdn.com/wpapps"));
}
// Click Button to share Web Link
private void btnShareLink_Click(object sender, RoutedEventArgs e)
{
Windows.ApplicationModel.DataTransfer.DataTransferManager.ShowShareUI();
}
来源:https://stackoverflow.com/questions/24924949/how-to-use-sharelinktask-namespace-in-windows-phone-8-1