Reputation: 21
How do I link a button to url, so that when the button is pressed, it opens a web browser and goes to specific URL? (Windows phone 8). using windows phone silverlight 8
Upvotes: 2
Views: 1885
Reputation:
It's super simple!
WebBrowserTask namewhatevz = new WebBrowserTask();
namewhatevz.Uri = new uri("http://google.se", UriKind.Absolute);
namewhatevz.Show();
Regards!
Bachir Bouchemla
Upvotes: 4
Reputation: 1181
Just register a Click
event on your button and in the event handler use LaunchUri
:
To do so, go to your .xaml and edit your Button.
<Button x:Name="LinkButton" Click="Button_Click" Content="Click here" />
Your Button
LinkButton now executes code behind function Button_Click when you click it.
Place the following function to code behind xaml.cs.
private void Button_Click(object sender, RoutedEventArgs e)
{
await Launcher.LaunchUriAsync(new Uri("www.google.com"));
}
Upvotes: 0