Error Template for DatePicker

Nov 11, 2008 at 9:10 PM
I'm trying to figure out how to change the appearance of the date picker, but I'm not sure where to go.  I'd just like to give the control a red background when an invalid date is entered - can someone please give me a push in the right direction.  I'm new to both WPF and the control toolkit.

At first I thought I would want to go down into

<

Validation.ErrorTemplate>
     <ControlTemplate>

 

but that would require me to re-draw the whole thing.  Is there any way to set a style trigger for this?

Thanks!
Sep 22, 2009 at 6:49 PM

Hi ,

Can any1 Provide us solution for above problem

 

With Regards,

Mahender

Sep 22, 2009 at 6:55 PM
Edited Sep 22, 2009 at 6:55 PM

Ha - good luck.  I've learned the hard way to stay the hell away from anything on CodePlex.  It's just a way to download half-complete controls in between .NET releases.  Oh, and while I'm on my rant, let me say also - stay away from WPF anyway.  It's just not worth it.  Go build a nice RIA with jQuery.  Might not have as many gradients in it, but it'll be solid, maintainable by normal developers, and a lot faster (and fun) to write.

Ok, rant over.  Sorry I don't have an answer to your question.

Coordinator
Sep 22, 2009 at 8:32 PM

Hi arackaf, sorry to hear that you've had such an unfortunate experience with the DatePicker.  When we shipped the controls on Codeplex, we shipped them "as is".  From time to time we triage concerns and questions on here and fix these bugs in our codebase.  And about every 3 months we release a new version of the WPF Toolkit with additional fixes.

For what it's worth, here's a potential solution to the issue you originally stated.  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.