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