I have a DateTime property (say, DateVal) in my viewmodel class and a DatePicker control in View.
<DatePicker Grid.Column="1"
Width="100"
Height="30"
SelectedDate="{Binding DateVal,ValidatesOnDataErrors=True}"/>
Problem is that, if the user deletes the date displayed in textbox of Datepicker control ,DateVal property is not changing its value. How can I track that the user has removed the Date displayed in datepicker textbox? regards, Anirban
The Date picker control looks like the following
Now if the user just removes the date displayed in date picker text box, the control looks like the following
At that point of time value of DateVal is same as before.
Only when the user clicks on the calender icon Date is assigned a value null.
How can I track the change at the same time when the user makes the text box empty ?
ViewModel Code
public DateTime? DateVal
{
get
{
return this.dateVal;
}
set
{
this.dateVal = value;
this.OnPropertyChanged("DateVal");
}
}
xaml code
<DatePicker Name="datePickerDateVal"
Grid.Column="1"
Width="100"
Height="30"
SelectedDate="{Binding DateVal,ValidatesOnDataErrors=True}"
Text="{Binding DateVal,ValidatesOnDataErrors=True,UpdateSourceTrigger=PropertyChanged}" />
I want that the setter property of DateVal must be called when the user clears the Date Picker text box