This section is about navigation. Read it again, found that more can not be achieved, because the version is updated, so many old syntax does not support, for example, no longer have navigationapplication, the Application,textblock container is still the TextWrap property changed to Textingwrap,startupuri points to "Page1.xaml". As long as wpfapplication (not browser) shows page pages, the navigation bar will automatically be generated.
Now let's look at Page1.xaml.
Example 1-16. A sample navigation page
<!-- Page1.xaml -->
<Page
x:Class="MyNavApp.Page1"
xmlns="http://schemas.microsoft.com/winfx/avalon/2005"
xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005"
Text="Page 1">
<TextBlock FontSize="72" TextWrap="Wrap">
Check out
<Hyperlink NavigateUri
="page2.xaml">page 2</Hyperlink>,
too.
</TextBlock>
</Page>
The key is this sentence:
<Hyperlink NavigateUri="page2.xaml">page 2</Hyperlink>
Equivalent to the following background code:
NavigationService.GetNavigationService(this).Navigate(new Uri ("page2.xaml", UriKind.Relative));
Among them, NavigationService is a class that provides static navigation methods, and two methods are responsible for backward and forward:NavigationService.GetNavigationService(this).GoForward();
NavigationService.GetNavigationService(this).GoBack();
Can be placed in the button event to complete the navigation.
Examples of supporting source code are available (Wpfprereleasebooksamples\ch01\beta2\mynavapp).