Default URI mapping conventions

When you first upgrade your Application you may experience an exception of type System.InvalidOperationException with the message: No XAML was found at the location '/Views/MainPage.xamlView.xaml'.

This is because the Defult URI Mapping expects your MainPage to be named MainView and "Main" to be listed as your NavigationPage in the DefaultTask element of the WMAppManifest.xml (located in the Properties folder)

You can override this in two ways:
  1. Override the AddUriMappings method in the App.xaml.cs
  2. Accept the default URI mapping conventions
    1. Change NavigationPage to Main in WPManifest.xml
    2. Change the MainPage.xaml view to MainView.xaml
    3. Move this MainView.xaml to a top level folder called Views

Mapping conventions

There are two conventions by default, they both expect all Views to be suffixed with the word View. eg. ApplicationSettingsView they are:
  1. /{page} and navigates to the Mapped URI /Views/{page}View.xaml eg. "ApplicationSettings" = /Views/ApplicationSettingsView.xaml
  2. /{noun}/{verb} and navigates to the Mapped URI /Views/{noun}{verb}View.xaml eg. "/Person/Create" = /Views/PersonCreateView.xaml

Navigation using Presenters

You can access the NavigationService directly in your Page Presenters via the View property eg. View.NavigationService.Navigate(Uri uri) or you can navigate using the following methods on the PagePresenter<TView> base class:
  1. NavigateTo(string page) and maps to /{page}
  2. NavigateTo(string noun, string verb) and maps to /{noun}/{verb}

The PagePresenter<TView> base also includes a GoBack() method.

Last edited Jan 22, 2011 at 8:47 PM by hoffmanic, version 2

Comments

No comments yet.