0

I have Windows Phone 8.1 app and I need to navigate from a main page to page "pizdec" with parameteres.

I have a cod which can do it in WP8.0, but how car rewrite it in code WP8.1, I don't know.

Example:

private void listbox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
   {
     if (listbox1.SelectedItem != null)
     {
        var file = listbox1.SelectedItem as StorageFile;
        NavigationService.Navigate(new Uri("/pizdec.xaml?filename=" + file.Name, UriKind.Relative));
        listbox1.SelectedItem = null;
     }

I know that I need use this.Frame.Navigate() , but I do not understand how to rewrite it to 8.1

Code from pizdec.xaml:

protected override void OnNavigatedTo(NavigationEventArgs e)
   {
      base.OnNavigatedTo(e);
      string filename;

    if(NavigationContext.QueryString.TryGetValue("filename",out filename))
    {
        DisplayFile(filename);
    }

And NavigationContext, which no in 8.1

Please help

Nima Derakhshanjan
  • 1,380
  • 9
  • 24
  • 37
feofan
  • 33
  • 8
  • possible duplicate of [Windows Phone 8.1 - Page Navigation](http://stackoverflow.com/questions/23154359/windows-phone-8-1-page-navigation) – Abhishek May 21 '15 at 13:29

1 Answers1

1

You use following,

Frame.Navigate(typeof(pizdec), param); //a Windows app syntax. param is parameters you want to pass to pizdec.xaml

You can access the paramaters in next page as follows,

string filename = e.NavigationParameter as string;

Microsoft is trying to make syntax of Windows & windows phone app similar, hence the change. More info here

Abhishek
  • 6,912
  • 14
  • 59
  • 85