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...
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With