Validations on DatePicker

Sep 22, 2009 at 2:30 PM


Can any1 tell me how to set red border across Datepicker whenever selected date goes beyond my date range.Please help me how to show red border whenver there are some validation for Datepicker control in wpf


With regards,


Sep 22, 2009 at 8:40 PM

Hi mahens,

What we recommend is getting a hold of the template part (using myDatePicker.Template.FindName API) for the text box ("PART_TextBox").  Then you can hook into the TextChanged event and parse the text in the textbox to a valid date format.  And proceed accordingly.  For example, pop up an error message or change the background color of the DatePicker.

Hope that helps,

Saied K.

Sep 23, 2009 at 10:58 AM

Thnx Saied...

Dec 29, 2009 at 7:36 PM


I am relatively new to WPF and need to hook into this event for the DatePicker control. Can you give some more guidance to how to do this?

Many Thanks,