RadDatePicker的设置默认值设置为NULL时未设定日期 [英] Set default value of RadDatePicker to NULL when date is not set
问题描述
我绑定RadDatePicker到一个ViewModel日期时间属性。当属性是在数据库空我得到01/01/0001。如何改变我这种行为给刚刚离开的日期字段为空.. 例如:
I'm binding the RadDatePicker to a viewModel dateTime property. when the property is null in database i get 01/01/0001. How to i change this behavior to just leave the date field blank.. example:
在数据库===> experiation_date:NULL 在View(GUI)===> experation_date:01/01/0001
In database ===> experiation_date : NULL In View(GUI) ===> experation_date : 01/01/0001
预期结果===> experation_date:{空白}
Expected Result ===> experation_date : {Blank}
推荐答案
设置将selectedDate为空(不是为DBNull):
Set the SelectedDate to null (and not DBNull):
RadDatePicker1.SelectedDate = null;
和在XAML中设置DateTimeWatermarkContent为空字符串:
and in xaml set DateTimeWatermarkContent to the empty string:
<telerik:RadDatePicker x:Name="RadDatePicker1" DateTimeWatermarkContent="" />
这篇关于RadDatePicker的设置默认值设置为NULL时未设定日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!