Reputation: 283
I want to navigate to a web link when I press a button. I think it's the same idea as navigating to a XAML page, but instead I put a web page.
Simple page navigation:
NavigationService.Navigate(new Uri("Page.xaml", UriKind.Relative));
I wrote
NavigationService.Navigate(new Uri("http://www.youtube.com", UriKind.Absolute));
But when I debug, the app crashes
I am using c#. (Visual Studio 2012 Express for windows phone 8)
Upvotes: 0
Views: 59
Reputation: 26635
You said that:
I think it's the same idea as navigating to a XAML page, but instead I put a web page.
But you cant use NavigationService to navigate to the web page.
I have used this way in one of my projects:
<HyperlinkButton Content="YouTube" NavigateUri="http://youtube.com" TargetName="_blank" />
The key is TargetName
property. It must be set to _blank
. This behaves similar to WebBrowserTask.
Of course you can make it work like this also:
WebBrowserTask webBrowserTask = new WebBrowserTask();
webBrowserTask.Uri = new Uri("http://www.youtube.com", UriKind.Absolute);
webBrowserTask.Show();
Upvotes: 1