WPF Notes (1.2 navigation navigation)--hello,wpf!

Source: Internet
Author: User
Tags xmlns

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).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.