Tag Archives: Navigation

UriMapping for WP7

15 Dec

UriMapping for Silverlight is pretty straight forward and if you use the Silverlight Navigation template you get it all from the template. WP7 contains many of the same features – it’s just not that obvious.

By default a WP7 app navigate using a PhoneApplicationFrame. PhoneApplicationFrame inherits from Frame – the control used in Silverlight. The PhoneApplicationFrame control is exposed as a property named RootFrame in App.xaml.cs.

To enable UriMapping in WP7 from the code you need to follow a few simple steps:

  1. Create a new method (in App.xaml.cs) that will set the UriMappings you need. In the method you need to make a new instance of UriMapper and for each mapping you wish to create you need to instantiate a new UriMapping specifying the Uri and MappedUri.
  2. Bind the mappings with the UriMapper instance and set RootFrame.UriMapper to the UriMapper instance.
  3. Call the method right after the RootFrame have been instantiated – typically in InitializePhoneApplication.
  4. Modify the existing start page in WMAppManifest.xml to make it fit your mappings.

In the sample below I have added two mappings; a default mapping and a mapping for a detailsview.

2010-12-15_152217

To use your mappings simply call your pages using a relative Uri:

2010-12-15_153430

You can download a demo here.

by xamlgeek
@thomasmartinsen

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

Frame and Page Navigation Overview for Windows Phone

23 Sep

Most Silverlight browser and out-of-browser applications can benefit from using Frames and Navigation. Silverlight applications on Windows Phone almost need Frames and Navigation. This little article gives a good overview of the terms and explain how and where to use the different parts.

by xamlgeek 
twitter.com/thomasmartinsen