Here we are learning how to navigate in a basic two page peer-to-peer Universal Windows Platform app.
Our app navigates between two pages, but it really doesn't do anything interesting yet. Often, when an app has multiple pages, the pages need to share information. Let's pass some information from the first page to the second page.
Step 2: Copy and paste the following code to the cs page which will be called on button clicking event and will pad the data along while navigating to our MainPage
- private void submit_Click(object sender, RoutedEventArgs e)
- {
- this.Frame.Navigate(typeof(newPage), name.Text);
- }
Step 3: Copy and paste the following code to the newPage by overriding OnNavigatedTo event.
- protected override void OnNavigatedTo(NavigationEventArgs e)
- {
- if (e.Parameter is string)
- {
- nameRecieved.Text = "Hi " + e.Parameter.ToString();
- }
- else
- {
- nameRecieved.Text = "Hi ";
- }
- }
Step 4: Run your application and test yourself.