Wp8.1 study1: page navigation & cross-page value transfer

Source: Internet
Author: User

Abstract: Many APIs in wp8.1 and WP8 are different. wp8.1 removes the APIs used in wp7.x, which is more similar to win8.1 APIs. For example, the value transfer between the following page navigation and page

 

1. page navigation

Using the frame. navigate () method, the C # statement is as follows:

1 frame. navigate (typeof (page2); // page2 is the name of a page.

Note that this method can be reloaded, that is, the cross-page value transfer method described later.

2. Cross-page value transfer

Frame. navigate () is used to transfer a single value and multiple values.

1) single value transfer: data such as characters and numbers can be transferred, such

In page1.xaml. CS

1 na=myTextbox.text;2 Frame.Navigate(typeof(Page2), na);

In page2.xaml. CS

// Receive transmitted data in the onnavigate () method protected override void onnavigatedto (navigationeventargs e) {mytextblock. Text = E. Parameter. tostring ();}

 

2) multi-value transfer: the basic method is the same as the single-value transfer method.

The reference method is as follows:

First create a class

namespace navigateSample{    public class NavigateContext    {         public string name { get; set; }         public int id { get; set; }        public NavigateContext(string name, int id)         {             this.id = id;             this.name = name;         }    }}

Then use the navigatecontext class for multi-value transfer

Navigatecontext NA = new navigatecontext (mytextbox. text, (INT) myslider. value); frame. navigate (typeof (page2), Na); // mytextbox is the textbox on the page. name, myslider is the slider on the page. name

In page2.xaml. CS

        protected override void OnNavigatedTo(NavigationEventArgs e)        {            var na = (NavigateContext)e.Parameter;            myTextblock1.Text =na.name;            myTextblock2.Text = na.id.ToString();        }

Summary: The above knowledge is learned by Bob's video. If you have any questions, please point them out!

Wp8.1 study1: page navigation & cross-page value transfer

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.