Oxygene and WP8 – Navigation in Windows Phone 8 (Part2)

Pass data between Pages in Windows Phone

One of the most common task when performing the navigation in a windows phone app is to pass the data from one page to another.

The NavigationContext in Windows Phone enables the developers to pass the QueryString from the source page and retrieve it in the destination page.

To send the data from the source page to the destination , the value has to be passed as parameter along with the Uri as shown below

NavigationService.Navigate(new Uri("/MainPage2.xaml?Message=User is SenthilKumar", UriKind.Relative));

In the destination page , use the NavigationContext.QueryString to retreive the value by key.

NavigationService.Navigate(new Uri("/MainPage2.xaml?Message=User is SenthilKumar", UriKind.Relative));

Navigate to External Uri in Windows Phone 8

There are times when the user wants to navigate to an external Url from the Application.

Below are few of the ways in which one can navigate to an external Uri in Windows Phone 8

1. Using WebBrowserTask

2. Using HyperLinkButton

The WebBrowserTask is a launcher which lets the users to launch the browser on the phone to open the specified Uri. Just instantiate the WebBrowserTask , specify the Uri ( in the example , lets use http://www.developerpublish.com ) and then call the show method as shown below.

var browser: WebBrowserTask := new WebBrowserTask();

browser.Uri := new Uri('http://www.developerpublish.com');

browser.Show();

When the above code is executed (say in the button click etc) , the WebBrowserTask should open http://www.developerpublish.com in the browser.

Oxygene and WP8 - Navigation in Windows Phone 8 (Part2)

Like WebBrowserTask , the HyperlinkButton can also be used to launch the external Uri or website . For example , to launch the site http://www.developerpublish.com using HyperLinkButton , specify the NavigateUri to “http://www.developerpublish.com” and also set the TargetName=”_blank”. When the Application is launched and the HyperlinkButton is tapped , the browser will launch the website.

<HyperlinkButton Content="Visit developerpublish.com" NavigateUri="http://www.developerpublish.com" TargetName="_blank"/>

Download the sourcecode used in this article here

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn about the Win32 Error “0x000019E5 – ERROR_COULD_NOT_RESIZE_LOG” that you get when debugging system erors in...
In this post, you’ll learn about the error “CO_E_DBERROR 0x8004E02B” that is returned when working with COM based APIs or...
In this post, you’ll learn about the Win32 Error “0x000019D0 – ERROR_LOG_BLOCK_VERSION” that you get when debugging system erors in...