NullReferenceException when calling NavigationContext
c#, windows-phone-7
Solution
I bet you are accessing `NavigationContext` in the constructor. The framework hasn't filled that in yet at that point. Check it in `OnNavigatedTo` or any time after and you should be fine.
Problem
In a Click function I use ``` NavigationService.Navigate(new Uri("/MainPage.xaml?day=" + this.week.SelectedIndex, UriKind.Relative)); ``` to navigate to MainPage.xaml with a value which indicate the Panorama.DefaultItem,and in MainPage.xaml.cs I write like ``` if (this.NavigationContext.QueryString.ContainsKey("day")) { schedule.DefaultItem = NavigationContext.QueryString["day"]; } ``` but a NullReferenceException comes out in ``` this.NavigationContext.QueryString.ContainsKey("day") ``` and I don't know where the wrong is,I will be appreciate if somebody can help me with this problem...