WPF Date Time Picker
[updated 09th Febuary 2008 - Bug fix for DateTimePicker]
After loads of requests for a DateTimePicker in AvalonControlLibrary I finally had sometime to build a DateTimePicker. DateTimePicker is nothing really special it is a DatePicker and a TimePicker combined in one control.
DateTimePicker exposes an important property called DateTimeSelected. DateTimeSelected is a dependency property so that you can use it in data binding. DateTimePicker also exposes an event DateTimeSelectedChanged that is raised whenever the date/time is changed.
There are some other useful properties that you can set to layout this control
MinuteHand - This property takes a Brush and it is used to color the minute hand
HourHand - This property takes a Brush and it is used to color the hour hand
ClockBackground - This property takes a Brush and it is used as Background color for the clock
CalanderHeaderBackground - This property takes a Brush and it is used as Background for the header of the calander
CalanderHeaderForeground - This property takes a Brush and it is used as Foreground for the header text of the calander
This control also supports control templates. You MUST supply a DatePicker named PART_DatePicker and a TimePicker named as PART_TimePicker in order to create a ControlTemplate for this control.
This control will ship in v2 of AvalonControlLibrary. If you have any suggestions or find any bugs please let me know so that I can update it before I release AvalonControlLibrary v2.
Please note that a new version is available here






[...] See also DatePicker See alse DateTimePicker [...]
[...] See alse DateTimePicker [...]
nice work
thanks
This is looking great, Marlon. Thank you!
I’m wondering if this control supports European weeks starting at Monday, which I’ll probably find out after downloading :).
For business applications it would also be a great option to display the week number to the left of each week using a specific CultureInfo, CalendarWeekRule and FirstDayOfWeek:
int weekno = specifiedCultureInfo.Calendar.GetWeekOfYear(dateInWeek, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday)
Cool..will test this in the weekend
Thanks for the control
Hi horst,
Thanks for the suggestion. I will have a look at it and update this for AvalonControlsLibrary v2
Thanks again
|Regards
Thanks Chaks….
Hello again, Marlon.
Just in case you consider adding support week numbers:
I just discovered that FirstFourDayWeekRule
and the GetWeekOfYear method is broken and does not produce
week numbers according to ISO 8601.
Maybe a function to produce the correct week numbers could be passed to the control.
Hi there,
Thanks for this… I will look into it. if you have any more ideas that you would like to share I would suggest that you send me an email on marlongrech@gmail.com
Thanks a lot and a lot
Hello everyone,
While refactoring code for DateTimePicker and making Routed events for time picker and datepicker, I found a major bug in the DateTimePicker control. The bug is basically when you set the date time manually the time is not set correctly! Thanks to the unit tests this was detected while I was refactoing the control and now it should be fixed. I uploaded the new version of the control. Sorry for any inconvience.
Regards
I can’t seem to get this to work in an XBAP application (the control doesn’t appear at all). Do you know of any way to get this to work in an XBAP or is it not possible b/c of the sandbox… thanks -
Are you using .net 3.5?
yes, i tried building it in both 05 and 08 and i’m running 3.5 framework. I’m also building it as a ‘full trust application’ according to the property settings. The page loads fine with no errors - just the control is invisible/blank (i can still see the text box controls though). I’ve seen this with other controls also - could it be because the control has ‘popup’ markups? i’ve read something about this in other forums… Thanks for the help
figured out the issue - i was trying to create a UserControl from your project and my project name was different from yours. In your Generic.xaml you had the project name listed in your code:
just changed the ‘DateTimePickerDemo’ to my project name and everything is good now.
Thanks for the great component!
Great job Kelly… 5 stars for u
Added support for Min and Max date
http://marlongrech.wordpress.com/2008/03/03/support-for-mindate-and-maxdate-in-datepicker-and-timepicker/
I use this control and it works fine for english culture. Please can u tell me how can I make it work for other cultures like de-DE at run time? Thanks
Is it posible to navigate through the control just with keyboard? To spring from month’s field to year’s to day’s … It should be used on a tv with a remote control.
Is there any method to get the popUp open when the control
gets the keyboard focus?
Thanks!
Hi,
can you post some code for databinding?
It seems not to work in my solution…
My code looks like this:
if you download the source code there are examples of how to databindind to the TimePicker
Hi,
i just found how to bind to a textbox…
I wanted to bind it to da row of a dataset where the datetime may be null…
If this is not possible i need to know how to display no date… Can you tell me how i can do this?
Hi there,
There is no feature in the current version of the date picker to display no date…. I would suggest that you disable the datepicker control when the date is null… You can do this via a trigger or converter…. If you want send me an email and I can send you a sample or something…
Regards
(1) i want to manualy enter date instead of selecting with mouse, how is it possible?
(2) how can i change the background on keyboard focus?
I want to highlight current date and time when
date time control first time drop down.
Once we select date, then it highlights that date
when it is drop down but i want to highlight current
date when it is first time drop down.
Please help me if you have any ideas
Thank You
Sanjay L. Dholakiya
I did not understand what you mean can you please repeat
Hi,
I want the combobox textbox editable so that the user can edit the date directly without opening the combobox, how can this be done.
Hi Marlon Grech, this is a lovely control, I needed this .. thanks for the help.
link is not opening ..
anyone can send me the code???
I just updated the link. Can you please try again.
Hi, nice control
I just expected the time to be editable by dragging the niddles on the watch too :p
That would be a cool feature to use with a stylus, as I’m developping apps for TabletPC!
Also, The dropdown with the month has an error, the November is spelled Novemeber, and that throws an exception when you choose it directly.
Regards,
Stéphane
Just a newbie learning, SHOCKED at the ease I was able to use Avalon Controls(DateTimePicker)Clicked on Designer inVS2008 Express , hit General area in toolbox “Choose Items…”, browsed to Avalon ,still on desktop & away we Go ! Dayum !
THANKZ Pal, NOT one word of code just dragged onto the form,
( Like I said, a newbie !) Thankz again, been Googleing for hours for help !
BLESS YOU !!!!!