This project is read-only.
The NavigationService allows a developer to navigate to other pages inside a Windows Phone 7 application using view models only.

The service will automatically determine all pages inside the application domain that implement the PhoneApplicationPage<TViewModel>. Other windows will have to be registered manually or following the right naming convention.

Available for
WPF / Silverlight / WP7 / WP7 Mango

Test/Emulation service available: yes

For WPF and Silverlight, the pages must inherit from Page<TViewModel>. For WP7, the pages must inherit from PhoneApplicationPage<TViewModel>.

In WPF, the parameters are of type Dictionary<string, object>, in Silverlight and WP7, the arguments are of type Dictionary<string, string>.

Navigating to a new view
To navigate to a new page, use the following code:

var navigationService = GetService<INavigationService>();

Navigating with parameters
It is very easy to navigate to a new page with parameters. Use the following code:

var parameters= new Dictionary<string, object>();
parameters.Add("id", employee.EmployeeID);

var navigationService = GetService<INavigationService>();

Navigating back and forward
The service also supports navigating back and forward:

var navigationService = GetService<INavigationService>();
navigationService.GoBack(); // navigates to the previous page, obviously
navigationService.GoForward(); // navigates to the next page, obviously

Navigating to a custom Uri
To navigate to a custom uri without a view model type, use the following code. Of course it's also possible to pass parameters using the right method overload.

var navigationService = GetService<INavigationService>();

Registering custom views
To register custom views, use the following code:

var navigationService = GetService<INavigationService>();
navigationService.Register(typeof(EmployeeViewModel), typeof(EmployeeDetailsPage));

Last edited Jul 18, 2011 at 4:51 PM by GeertvanHorrik, version 3


No comments yet.