I am trying to get a parameter from the URL but I am getting an error. Here is my code:
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
string str = "";
if (NavigationContext.QueryString.TryGetValue("data", out str))
{
MessageBox.Show("k");
}
}
private void aktualizuj(object sender, DateTimeValueChangedEventArgs e)
{
var btndate = sender as DatePicker;
NavigationService.Navigate(new Uri("dieta.xaml?data=" + btndate.Value.Value.Date.ToString(),UriKind.Relative));
}
The error I am receiving is as follows:
A first chance exception of type 'System.MissingMethodException' occurred in mscorlib.ni.dll
If there is a handler for this exception, the program may be safely continued.
Hmmm, looks like your debugger is getting quirky.
NavigationService.Navigate(new Uri("dieta.xaml?data=" +
btndate.Value.Value.Date.ToString(),UriKind.Relative));
Should throw the exception:
Navigation is only supported to relative URIs that are fragments, or begin with '/', or which contain ';component/'. Parameter name: uri
So you should change it to
NavigationService.Navigate(new Uri("/dieta.xaml?data=" +
btndate.Value.Value.Date.ToString(),UriKind.Relative));
If you're going to use UriKind.Relative
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.