检查DatePicker值是否为null [英] Check if DatePicker value is null
本文介绍了检查DatePicker值是否为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想检查 DatePicker
的值是否为空(==框中没有日期)。
I would like to check if the value of a DatePicker
is null (== no date in the box).
默认情况下,我的 DatePicker
的文本
设置为日期
,所以我不能使用 Text
属性进行检查。
By default the Text
of my DatePicker
is set to something like Select a date
, so I can't use the Text
property to check.
推荐答案
DatePicker类具有一个属性, SelectedDate ,使您能够获取或设置所选日期。如果没有选择,则表示其值为空。
The DatePicker class has a property, SelectedDate, which enable you to get or set the selected date. If there is none selected, it means its value will be null.
if (datePicker.SelectedDate == null)
{
// Do what you have to do
}
这篇关于检查DatePicker值是否为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文