locked
Navigation in Windows Phone 8.1 app RRS feed

  • Question

  • I'm a newer in Silverlight for windows Phone. I want to know how can I navigate between different pages in Windows Phone app? And I want to transfer parameters when page navigation.

    In addition, how can I back to the previous page in Windows Phone.

    Thank you very much!

    Monday, August 24, 2015 2:08 PM

Answers

  • Hi MMDDYY,

    Please use the NavigationService.Navigate method to implement navigation between pages as below code.

    private void hyperlinkButton1_Click(object sender, RoutedEventArgs e)
    {
       NavigationService.Navigate(new Uri("/SecondPage.xaml", UriKind.Relative));
    }

    And if you want to transfer parameters when page navigation, please add parameters after the page's uri as following.

    private void passParam_Click(object sender, RoutedEventArgs e)
    {          
       NavigationService.Navigate(new Uri("/SecondPage.xaml?msg=" + textBox1.Text, UriKind.Relative));
    }

    If you want to go back to pre-page, please call NavigationService.GoBack() method as below. If you want to use the Back Button, please refer to following link.

    private void button1_Click(object sender, RoutedEventArgs e)
    {
       NavigationService.GoBack();
    }

    https://msdn.microsoft.com/en-us/library/windows/apps/xaml/Dn639128.aspx

    Best Regards,
    Weiwei

    • Marked as answer by MMDDYY Tuesday, August 25, 2015 1:11 PM
    Tuesday, August 25, 2015 2:12 AM
    Moderator