问题
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:
In database ===> experiation_date : NULL In View(GUI) ===> experation_date : 01/01/0001
Expected Result ===> experation_date : {Blank}
回答1:
Set the SelectedDate to null (and not DBNull):
RadDatePicker1.SelectedDate = null;
and in xaml set DateTimeWatermarkContent to the empty string:
<telerik:RadDatePicker x:Name="RadDatePicker1" DateTimeWatermarkContent="" />
回答2:
If you are bind not nullable datetime variable i.e (DateTime) to control then it will use default 01/01/001 date instead of Empty.... So if you want the default value as a Empty then just change the datatype of your variable which is bound to control to (DateTime?).....
DateTime ===> DateTime?
It works fine...
Thank you.!!!
来源:https://stackoverflow.com/questions/10207038/set-default-value-of-raddatepicker-to-null-when-date-is-not-set