I am attempting to create a hyperlink from an existing url that I would like to ‘share’ with others. What I mean to say is that I am creating a ‘share page’ option for my phone app and I pass the current url via querystring to my SharePage.xaml, whereby the user may select an option to share the current url that the webbrowser control is on. For instance, in my SharePage.xaml.cs my code is as follows:
SharePage.xaml.cs
string urlToShare;
public SharePage()
{
InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
//base.OnNavigatedTo(e);
NavigationContext.QueryString.TryGetValue("curUrl", out urlToShare);
}
private void SocialNetworks_Click(object sender, RoutedEventArgs e)
{
ShareLinkTask shareLinkTask = new ShareLinkTask();
Uri shareUrl = new Uri(urlToShare);
shareLinkTask.Title = "Shared Link!";
shareLinkTask.LinkUri = shareUrl;
shareLinkTask.Message = "Check out this link!";
shareLinkTask.Show();
}
As of now this works although the LinkUri part of the message shows up as plain text instead of a hyperlink (which is what I would like to give as an option). The purpose would be to simply facilitate more efficient, quicker navigation to a url so that the user does not have to copy and paste the url into a web browser manually (something I’ve found annoying on the Windows Phone). Is there any way to do this in code behind in my SocialNetworks_Click event? Any code help or suggestions would be greatly appreciated, I have never messed with the Hyperlink option in C# as I am new to the language (and cannot find anything online about doing this in code behind if thats possible). Thanks in advance!
I think you’re confused about what the ShareLinkTask is supposed to do.
This isn’t meant to be displayed as a link in your app, or even in the task UI.
On the “Post a link” page this will be just text (and not tappable).
When the link appears in Twitter or Facebook or LinkedIn or whatever else you’re sharing to then it will be a valid link that can be tapped/clicked.