Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Phone 7 navigation to internet from an application

I have the following question: I have my Windows Phone 7 appplication and I have a HyperlinkButton with the NavigateUri binded to an Uri created like this:

Uri uri = new Uri("http://google/ro",UriKind.Ablosute)

but when I press the button I get the following error :

Navigation is only supported to relative URIs that are fragments, or begin with '/', or which contain ';component/'.\r\nParameter name: uri

What did I do wrong? Or is the WP7 that does not allow to surf the internet from an application with a HyperlinkButton? Since when I create the uri like Uri uri = new Uri("/Page.xaml",UriKind.Relative) it redirects me to Page.xaml in the project.

like image 942
zoltanflavius Avatar asked Dec 22 '10 15:12

zoltanflavius


2 Answers

I found a rather strange workaround that fixes this. Just add a TargetName="_blank" property to your HyperlinkButton control, and it magically starts working.

<HyperlinkButton Content="Google" NavigateUri="http://google.com" TargetName="_blank" />

Chris

like image 172
Chris Rae Avatar answered Nov 14 '22 04:11

Chris Rae


You can't use the phone navigation system to navigate to the web (where would you expect it to display?). But you can use the web browser control to display web pages in your app. See this example

You could also use a Web Browser Task something along the lines of

WebBrowserTask wtb = new WebBrowserTask();
wtb.Uri = new Uri("http://www.google.com", UriKind.Absolute); 
wtb.Show(); 
like image 3
Fishcake Avatar answered Nov 14 '22 04:11

Fishcake