Hi All,
I am using the below mentioned DatePicker control in my windows universal app.
https://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.ui.xaml.controls.datepicker.aspx[
^]
The date picker value is always defaulting to current day. I wanted to make it null, but it is somehow not working. DateOfBirth is the bound value which is of type DateTimeOffset
Below is the XAML part
<DatePicker
Visibility="{Binding DateOfBirth.Visibility}"
IsEnabled="{Binding DateOfBirth.EditEnabled}"
Date="{Binding DateOfBirth.Value, Mode=TwoWay}" x:Name="myDatePicker"/>
In C# code:
Both of the below items are not working
1. In my View model where the DateOfBirth value is defined
DateTimeOffset? nullableDate = null;
DateOfBirth = nullableDate;
This results in showing the MinDate value.
or
2. In the XAML code behind
DateTimeOffset? nullableDate = null;
myDatePicker.Date = (DateTimeOffset)nullableDate;
This results in an InvalidOperation exception that nullableDate should have an value.
Any suggestions to make this null?
Thanks in advance