C# OnNavigate更改日期/时间选择器值-windows phone

C# OnNavigate更改日期/时间选择器值-windows phone,c#,windows-phone-7,windows-phone-8,datepicker,timepicker,C#,Windows Phone 7,Windows Phone 8,Datepicker,Timepicker,选中该复选框后,我希望能够获取日期选择器/时间选择器的值。发生的情况是,它能够获得值,但当我尝试更改值时,它不会更改,因为它只会返回到以前的值。我做错了什么?下面是我的代码: protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); if (NavigationContext.QueryS

选中该复选框后,我希望能够获取日期选择器/时间选择器的值。发生的情况是,它能够获得值,但当我尝试更改值时,它不会更改,因为它只会返回到以前的值。我做错了什么?下面是我的代码:

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
    {
        base.OnNavigatedTo(e);


        if (NavigationContext.QueryString.ContainsKey("Id"))
        {
            Id.Text = NavigationContext.QueryString["Id"];

        }


        ScheduledAction currentReminder = ScheduledActionService.Find(NavigationContext.QueryString["Id"]);

        if (currentReminder == null)
        {
            cBox.IsChecked = false;

        }
        else 
        {
            cBox.IsChecked = true;
            rrDate.Value = currentReminder.BeginTime;
            hiddenTime.Text = rrDate.Value.ToString();
            rrTime.Value = DateTime.Parse(hiddenTime.Text);
        }
    }

当您尝试更改datepicker值时,每次都会将页面导航到事件激发。这是解决办法,希望这能对你有所帮助

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
    {
        base.OnNavigatedTo(e);
  if(e.NavigationMode!=NavigationMode.Back)
    {
        if (NavigationContext.QueryString.ContainsKey("Id"))
        {
            Id.Text = NavigationContext.QueryString["Id"];

        }
        ScheduledAction currentReminder = ScheduledActionService.Find(NavigationContext.QueryString["Id"]);
        if (currentReminder == null)
        {
            cBox.IsChecked = false;
        }
        else 
        {
            cBox.IsChecked = true;
            rrDate.Value = currentReminder.BeginTime;
            hiddenTime.Text = rrDate.Value.ToString();
            rrTime.Value = DateTime.Parse(hiddenTime.Text);
        }
      }
    }

谢谢你的回复。我已经试过了,是的,它现在起作用了。非常感谢!OnNavigatedTo call是对数据选择器和计时器上设置的每个值的免费礼物。