处理Datepicker和Timepicker事件 [英] Handle Datepicker and Timepicker events

查看:57
本文介绍了处理Datepicker和Timepicker事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法检测用户是否更改了日期选择器或时间选择器。

I am having trouble detecting if a datepicker or time picker has been changed by a user.

日期选择器在xaml中声明如下。

The date picker is declared in the xaml as follows.

toolkit:DatePicker Value =" {Binding StartTime,Mode = OneWay}" ValueChanged =" DatePicker_StartValueChanged"

toolkit:DatePicker Value="{Binding StartTime, Mode=OneWay}" ValueChanged="DatePicker_StartValueChanged"

当page_loaded完成后,DatePicker_StartvalueChanged会根据绑定值触发一次或两次。

When the page_loaded has finished the DatePicker_StartvalueChanged fires once, or twice depending on the binding value.

如果绑定值有一个值,事件第一次触发两次,newdatetime为null,olddatetime是今天@ 12am,下次触发newdatetime时设置为绑定值,olddatetime为null。当我更改日期选择器
的值时,newdatetime是新选择的值,olddate时间是绑定值。

If the binding value has a value, the event fires twice the first time, the newdatetime is null and the olddatetime is today @ 12am, the next time it fires the newdatetime is set to the binding value and the olddatetime is null. When I change the value of the date picker, the newdatetime is the newly selected value and the olddate time is the binding value.

但是,如果绑定值为null,则newdatetime为null,olddatetime为今天@ 12am。当我更改datepicker的值时,newdatetime是新选择的值,olddate时间为null。

If however, the binding value is null, the newdatetime is null and the olddatetime is today @ 12am. When I change the value of the datepicker, the newdatetime is the newly selected value and the olddate time is null.

如果用户实际更改了选择器的值并且需要忽略绑定生成的值,我只想做某事。我怎么能这样做?

I only want to do something if the user has actually changed the value of the picker and need to ignore the ones generated by the binding. How can I do this?

推荐答案

我该怎么做?


使用布尔值用于确定事件何时触发的标志?
Use a boolean flag to determine when event is firing?


这篇关于处理Datepicker和Timepicker事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆