0

I have a datePicker in my WPF application. The text property of datepicker is bound to a Nullable DateTime property in my view model. UpdateSourceTrigger is set to PropertyChanged.

The problem I am facing is when I enter today's date like 2/10, it posts back to the view model as '2/10/2014'. Is there something which I am doing wrong.

Is there any way to stop the partial date to be posted back to the view model on text change?

Also I do not wish to change my nullable DateTime to text.

thanks Sandeep

2
  • Don't bind the text property, bind the value property. Commented Oct 16, 2014 at 9:52
  • Can You Please Elaborate that why you need Partial Date ? If you really want your Partial Date then you can use DateValidationError method in that you will get Partial text you have entered and you can set value to the required date, Commented Oct 16, 2014 at 10:11

1 Answer 1

1

If you want to stop the update on text changing you should try set "UpdateSourceTrigger=LostFocus", in this way the source is going to be updated only once the datepicker lose focus.

Also I do not wish to change my nullable DateTime to text.

In this case you should bind to DatePicker.SelectedDate property.

Sign up to request clarification or add additional context in comments.

2 Comments

Actually on user entering a date, I enable the button to search based on the value, hence I cannot opt for user to tab out, hence propretychanged.
In case of SelectedDate property, PropertyChanged is triggered only on tab out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.