Re-worked as per Peter’s suggestion.
I have an xceed DateTimePicker. This accepts a DateTime? value to display and bind to.
I have a special date – 1900-01-01 00:00:00
If I pass this date into the DateTimePicker, I would like this to be treated as if I passed in null – ie, a date is not shown.
When I retrieve the value, if the date hasn’t been set ie null, I would like to return that same special date – 1900-01-01 00:00:00.
For all other dates, whatever goes in goes out.
In code behind I could do it like this (pseudo code):
DateTime SpecialDate = new DateTime(1900,1,1,0,0,0)
DateTime TestDate = new DateTime(2016, 2, 8, 10, 0, 0);
DateTimePicker dtp = new DateTimePicker();
// Setting value.
if (TestDate != SpecialDate)
dtp.Value = TestDate;
// Getting value
if (dtp.Value == null)
return SpecialDate;
else
return (DateTime)dtp.Value;
Can I achieve the same kind of thing using Xaml and binding ?