Note that there are some explanatory texts on larger screens.

plurals
  1. POValidation for DateTime property in viewmodel
    text
    copied!<p>I have a DateTime property (say, DateVal) in my viewmodel class and a DatePicker control in View.</p> <pre><code> &lt;DatePicker Grid.Column="1" Width="100" Height="30" SelectedDate="{Binding DateVal,ValidatesOnDataErrors=True}"/&gt; </code></pre> <p>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</p> <p>The Date picker control looks like the following <img src="https://i.stack.imgur.com/RTKQG.jpg" alt="Date picker before editing date picker text box "> Now if the user just removes the date displayed in date picker text box, the control looks like the following <img src="https://i.stack.imgur.com/AWdKi.jpg" alt="Date picker after editing date picker text box"> 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 ?</p> <p>ViewModel Code</p> <pre><code>public DateTime? DateVal { get { return this.dateVal; } set { this.dateVal = value; this.OnPropertyChanged("DateVal"); } } </code></pre> <p>xaml code</p> <pre><code>&lt;DatePicker Name="datePickerDateVal" Grid.Column="1" Width="100" Height="30" SelectedDate="{Binding DateVal,ValidatesOnDataErrors=True}" Text="{Binding DateVal,ValidatesOnDataErrors=True,UpdateSourceTrigger=PropertyChanged}" /&gt; </code></pre> <p>I want that the setter property of DateVal must be called when the user clears the Date Picker text box</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload