Use the pages in your application and use the NavigationService to switch between them.
For example, if you have two pages in your folder, "Page1" and "Page2", you can include the following in Page1.xaml:
<Button Content="Next" Click="NextClicked" />
and this is in your Page1.xaml.cs file:
void NextClicked(object sender, RoutedEventArgs e) { NavigationService.Navigate(new Page2()); }
Alternatively you can use this:
NavigationService.Navigate(new Uri("Page2.xaml", UriKind.Relative));
It is usually easier to do the first, because you can also set the page properties. For example, if Page2 has the public property "CurrentItem", you can say:
NavigationService.Navigate(new Page2 { CurrentItem = this.Something });
You cannot do this with Uri-based syntax.
You can also create instances of different pages (Page1, Page2, etc.) and save them in your application, and then switch to them as follows:
NavigationSerivce.Navigate(App.Page2);
That way, if you ever get to the page later, you get exactly the same Page2 object. Alternatively, you can use the NavigationService Journaling function to help with this.
Ray burns
source share