title: Get NullReferenceException on page load while get NavigationContext.QueryString
body: <p>I used the MVVM pattern to develop my Windows app. When the user click on the item on my listbox usercontrol. The code behind of the viewmodel will navigate the another page. The page is shown correctly, but the problem is I got an error -" NullReferenceException" when I want to get the queryString from Navigation context. I checked the uri on my viewmodel is corrected. Would some one show me how to make it work? Thanks in advance.</p>
  
  <p>I reference at <a href="https://stackoverflow.com/questions/6830123/an-error-is-occur-when-we-use-navigation-to-move-other-page">An error is occur when we use navigation to move other page</a> to add the following code on App.xamls.cs page, so the viewModel page can navigate another page.</p>
  
  <pre><code>    public static PhoneApplicationFrame CurrentRootVisual
      {
          get
          {
              return (App.Current.RootVisual as PhoneApplicationFrame);
          }
      }
  
      public static bool Navigate(Uri source)
      {
          if (CurrentRootVisual != null)
              return CurrentRootVisual.Navigate(source);
  
          return false;
      }
  
      public static void GoBack()
      {
          if (CurrentRootVisual != null)
              CurrentRootVisual.GoBack();
      }
  </code></pre>
  
  <p>There is code on viewModel to navigate the page:</p>
  
  <pre><code> private void ShowCallPage()
          {
              if (m_CurrentQueue != null)
  
                  App.Navigate(new Uri("/PivotPage1.xaml?id=" + m_CurrentQueue.callNumber, UriKind.Relative));
  
          }
  </code></pre>
  
  <p>There is the code I get error on the another page:</p>
  
  <pre><code> public PivotPage1()
      {
          InitializeComponent();
          MessageBox.Show(NavigationContext.QueryString.ContainsKey("id").ToString());            
  
      }
  </code></pre>