Parameters and Navigation in Windows Phone 7

13 Oct

Sending and retrieving parameters through page navigation can be really useful. Windows Phone 7 uses a navigation system that allows this feature using the NavigationContext and QueryString.

Sending a parameter

Sending a parameter is just like sending a QueryString parameter as part of an url and I use the NavigationService to navigate.

2010-10-13_012117

Receiving a parameter

Receiving a parameter is just as easy as sending it and just like receiving a normal QueryString parameter. To receive the parameter I’m using the NavigationContext that can retrieve QueryString parameters.

2010-10-13_012938

by xamlgeek
twitter.com/thomasmartinsen

4 Responses to “Parameters and Navigation in Windows Phone 7”

  1. Roboblob October 16, 2010 at 22:57 #

    Hi,

    take a look at my solution for Silverlight Navigation with Prism:

    http://blog.roboblob.com/2010/10/15/combining-silverlight-navigation-framework-and-prism-to-create-mvvm-applications-introduction/

  2. Gustaf Lindqvist October 17, 2010 at 14:57 #

    Feels like it’s dangerous to use QueryString to pass data between the navigation page? Thinking of magic strings and when to maintain an application.

  3. Adrian Aisemberg July 5, 2011 at 11:38 #

    Kick-ass WP7 navigation without passing any strings. Any object type is supported: http://www.sharpregion.com/easy-windows-phone-7-navigation/

    // source
    private void NavigateToSomePage()
    {
    NavigationService.Navigate(data);
    }

    // target
    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
    base.OnNavigatedTo(e);

    var data = NavigationContext.GetData();

    // continue
    }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: