2
votes

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
I used below code I am also getting a progress bar with a message Preparing content to share and then it disappears, with no UI for sharing. please help me.Anil Kumar

1 Answers

10
votes

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();
}