Web developers will find themselves in familiar territory with the navigation in Windows Phone 7.
NavigationService Class
Navigate to another page:
1 |
NavigationService.Navigate(new Uri("NewPage.xaml", UriKind.Relative)); |
Navigate to another page (with parameters):
1 |
NavigationService.Navigate(new Uri("NewPage.xaml" + "?ID=" + "15", UriKind.Relative)); |
NavigationContext Class
If a parameter was passed to the destination page using query string, NavigationContext class allows to read the query string as follows
1 2 |
string ID; NavigationContext.QueryString.TryGetValue("ID", out ID); |
Navigation History
Navigation history is exposed as a read-only enumeration through the property called NavigationServices.BackStack,
There are additional methods exposed for going back and forward one step at a time. It is a good practice to check for the CanGoBack and CanGoForward property before calling the navigation methods to make sure there is more in the history to go back or forward.
1 2 3 4 5 6 7 8 9 |
if (NavigationService.CanGoBack) { NavigationService.GoBack(); } if (NavigationService.CanGoForward) { NavigationService.GoForward(); } |