Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8506395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:34:45+00:00 2026-06-11T02:34:45+00:00

I used the MVVM pattern to develop my Windows app. When the user click

  • 0

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.

I reference at An error is occur when we use navigation to move other page to add the following code on App.xamls.cs page, so the viewModel page can navigate another page.

    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();
    }

There is code on viewModel to navigate the page:

 private void ShowCallPage()
        {
            if (m_CurrentQueue != null)

                App.Navigate(new Uri("/PivotPage1.xaml?id=" + m_CurrentQueue.callNumber, UriKind.Relative));

        }

There is the code I get error on the another page:

 public PivotPage1()
    {
        InitializeComponent();
        MessageBox.Show(NavigationContext.QueryString.ContainsKey("id").ToString());            

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T02:34:46+00:00Added an answer on June 11, 2026 at 2:34 am

    Don’t access the NavigationContext object on the PivotPage1 constructor, use the Loaded event instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an app using Windows Phone 7. I have used MVVM for
The application I'm currently writing is using MVVM with the ViewModel-first pattern. I have
I'm used to working in WPF with the MVVM design pattern, but I've recently
I need some help about MVVM pattern. I created a ViewModel that expose data
I have wholly adopted the MVVM pattern for our silverlight app. However, some of
I'm writing a Silverlight app using the MVVM pattern. I have a main view
I'm making a MessageBox control in WPF using the MVVM pattern. This MessageBox will
I forked from thread When using MVVM pattern, should code relating to property changes
I'm looking for code of full applications that (1) use the MVVM pattern and
ViewModel is a term that is used in both MVVM (Model-View-ViewModel) and the recommended

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.