0

I've run into an issue with passing parameters between pages. OnNavigatedTo is definitely being called but the if statement keeps returning false, when it should return true. Can anyone out there shoot me in the right direction?

The following is on my main page:

NavigationService.Navigate(new Uri("/Class_page.xaml?name=" + classes[0].name
                + "&code=" + classes[0].code + "&semester=" + classes[0].semester  
                + "&index=" + index, UriKind.Relative));

The following is on my "Class_page":

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    string cn, cc, sm, i, grd, oo, wg;
    if (NavigationContext.QueryString.TryGetValue("name=", out cn) &&
        NavigationContext.QueryString.TryGetValue("code=", out cc) &&
        NavigationContext.QueryString.TryGetValue("semester=", out sm) &&
        NavigationContext.QueryString.TryGetValue("index=", out i) )
    {
        /*it never reaches this point*/
        NavigationService.Navigate(new Uri("/test_page.xaml", UriKind.Relative));
        curr = Convert.ToInt32(i);
        grades[curr] = new class_gds(cn, cc, sm); //adds course to array
        class_name.Text = grades[curr].GetName();
        class_code.Text = grades[curr].GetCode();
        semester.Text = grades[curr].GetSemester();
    }
John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • Please don't change your title to include "solved:". We have better ways to indicate that the question has been answered. – John Saunders Sep 03 '14 at 02:05

1 Answers1

1

Change this:

if (NavigationContext.QueryString.TryGetValue("name=", out cn) &&
        NavigationContext.QueryString.TryGetValue("code=", out cc) &&
        NavigationContext.QueryString.TryGetValue("semester=", out sm) &&
        NavigationContext.QueryString.TryGetValue("index=", out i)

To this:

if (NavigationContext.QueryString.TryGetValue("name", out cn) &&
        NavigationContext.QueryString.TryGetValue("code", out cc) &&
        NavigationContext.QueryString.TryGetValue("semester", out sm) &&
        NavigationContext.QueryString.TryGetValue("index", out i)
Mangesh
  • 5,491
  • 5
  • 48
  • 71
Gabriel Isenberg
  • 25,869
  • 4
  • 37
  • 58