DateTimePicker

Derives from Xceed.Wpf.Toolkit.DateTimeUpDown

Get the best of both worlds: The user can increment or decrement the DateTime using button spinners, up/down keys, or the mouse wheel, or can modify the DateTime in the dropdown calendar.

DateTimePicker.jpg

Properties

Property Description
AllowSpin Gets or sets the ability to perform increment/decrement operations via the keyboard, button spinners, or mouse wheel. (Inherited from UpDownBase)
AutoCloseCalendar Gets or sets if the Calendar should close on a selection.
ClipValueToMinMax Gets or sets if the value should be clipped when minimum/maximum is reached. (Inherited from UpDownBase)
CultureInfo Gets or sets the current CultureInfo. (Inherited from InputBase)
DefaultValue Gets or sets the value to use when the Value is null and an increment/decrement operation is performed. (Inherited from UpDownBase)
DisplayDefaultValueOnEmptyText Gets or sets if the DefaultValue should be displayed when the Text is empty. (Inherited from UpDownBase)
Format Gets or sets a DateTimeFormat value representing the format to be used (FullDateTime, LongDate, etc.). (Inherited from DateTimeUpDown).
FormatString Gets or sets the display format to use when Format is set to Custom (e.g., "hh:mm tt") (Inherited from DateTimeUpDown).
IsOpen Gets or sets a value indicating whether the DateTimePicker is open.
IsReadOnly Gets or sets if the control is read only. (Inherited from InputBase)
Maximum Gets or sets the maximum allowed value. (Inherited from UpDownBase)
Minimum Gets or sets the minimum allowed value. (Inherited from UpDownBase)
MouseWheelActiveTrigger Gets or sets when the MouseWheel is active (Focused, FocusedMouseOver, MouseOver, Disabled). By default FocusedMouseOver. (Inherited from UpDownBase).
ShowButtonSpinner Gets or sets if the ButtonSpinners are visible. (Inherited from UpDownBase)
Text Gets or sets the formatted string representation of the value. (Inherited from InputBase)
TextAlignment Gets or sets the alignment of the Text. (Left, Right, Center, Justify). By default Left. (Inherited from InputBase)
TimeFormat Gets or sets the time format.
TimeFormatString Gets or sets the time format string used when TimeFormat is set to Custom.
TimePickerAllowSpin Gets or sets if the TimePicker in the DateTimePicker can Spin.
TimePickerShowButtonSpinner Gets or sets if the ButtonSpinners of the TimePicker in the DateTimePicker are shown.
TimePickerVisibility Gets or sets if the TimePicker in the DateTimePicker is visible.
TimeWatermark Gets or sets the time watermark.
TimeWatermarkTemplate Gets or sets the time watermark's data template.
Value Gets or sets the numeric value. (Inherited from UpDownBase)
Watermark Gets or sets the object to use as a watermark if Value is null. (Inherited from InputBase)
WatermarkTemplate Gets or sets the DataTemplate to use for the Watermark. (Inherited from InputBase)

Events

Event Description
InputValidationError Raised when the Text cannot be converted to a valid Value. (Inherited from UpDownBase)
ValueChanged Raised when the Value changes. (Inherited from UpDownBase)

Methods

Method Description
SelectAll Select all the Text from the TextBox in the DateTimePicker. (Inherited from DateTimeUpDownBase)


Support this project, check out the Plus Edition.
---

Last edited Jun 9 at 5:37 PM by dlafontaine, version 10

Comments

CrazyTasty Oct 5, 2013 at 3:11 AM 
I wondering why the DateTimePicker control has no BlackoutDates property. I was using a standard WPF DatePicker with a custom attached property that let me select ranges of blackout dates. I switched to the DateTimePicker control, but I'm struggling to get the attached property to work again.

BoucherS Jul 29, 2013 at 7:56 PM 
If you want to remove the dropDown button of a dateTimePicker, use a DateTimeUpDown.
Looks like the datetimepicker is updating after it lost focus when trying to edit the time manually.

sheenlim Jul 21, 2013 at 2:34 AM 
How can I remove the dropdown button of datetime picker?

Also, the datetimepicker is not updated after it lost focus when trying to edit the time manually.

BoucherS Nov 29, 2012 at 1:43 PM 
Yes that is true, but v1.9 fixes the problem. Please use the discussion or issueTracker tab to report issues.

tewnn Nov 29, 2012 at 1:18 PM 
Looks like it's impossible to enter date and time from keyboard in version 1.8.0. Is it true?

BoucherS Nov 1, 2012 at 1:39 PM 
To use the DateTimePicker without the Time selection and to close the Calendar on a Date selection, you can use the DatePicker. Unless you prefer the features from the Toolkit DateTimePicker. In that case we could have a look evaluate if those features are wanted.

juhav Nov 1, 2012 at 9:19 AM 
How can I hide the time selection? Is it possible for the calendar to close when date is selected?

emartin Oct 22, 2012 at 12:18 PM 
skroged, your comments on the following thread would be welcomed:
https://wpftoolkit.codeplex.com/discussions/400297

skroged Oct 19, 2012 at 2:21 AM 
+10 points for the widget. -`1000 for not making it conform to WPF standards. The selected DateTime needs to be a dependency property so it can be data-bound in xaml. It needs to be nullable.

I'm afraid it's rather unusable for me in it's current state. Good start though.

skst Oct 12, 2012 at 2:26 AM 
It'd be nice if there were an option to have the time to the left of the date. Or is the appropriate method for doing that to re-templatize the control? (That seems a bit extreme.)

midiman Aug 23, 2012 at 7:04 AM 
I also need the masked textbox. If the user types a separator, the cursor should be moved only.

caouellet Jul 26, 2012 at 5:31 PM 
As far as DateTime format goes and localization why not have used the windows and dot net framework's existing mechanics instead of a custom system

adondero Jun 8, 2012 at 9:35 PM 
I was wondering is there a way to add "Masked" edit to the date time picker.

We have our users using the format mm/dd/yyyy HH24:mi. Our product management would like to not have the users type the "/" or ":" and either have a masked text box or some sort of "format this date" method so we can apply our own formatting and add in the missing characters.

Any thoughts or help would be appreciated.

ybonda Jun 3, 2012 at 11:40 AM 
Good example of WPF DateTimePicker In DataGrid - http://www.codearsenal.net/2012/03/wpf-datetimepicker-in-datagrid.html

zaherz May 24, 2012 at 11:34 AM 
how come i can set min and max date values at the current updown button and to disable the dates that are out of range and to be effected by the time updown button that located at the calendar popup??

Imker May 11, 2012 at 9:24 AM 
If you want to set the focus to a datetimepicker in codebehind,
use the property Focusable="True", so the datetimepicker can get the focus.

zhoufoxcn Mar 31, 2012 at 3:04 PM 
great!thanks!

jpnavarini Mar 14, 2012 at 4:52 PM 
Is it possible to add seconds into the time picker, below the calendar?
I can use the spin up and down in the text box to change the seconds, but I would like to do it when the calendar is open, using the up and down spinners of the time picker.

plansoft Feb 13, 2012 at 9:27 PM 
Would be nice if setting the height (i.e. 22) would not hide part of the text/value. Seems to have a fair amount of padding (and no, changing padding does not have an effect). Smaller height necessary in our case for complex data entry forms where space is at a premium. All other standard WPF controls size very well.

skst Dec 1, 2011 at 3:54 PM 
Properties:

bool IsOpen

object TimeWatermark
DataTemplate TimeWatermarkTemplate

string FormatString

DateTime DefaultValue
DateTimeFormat Format

DateTimeFormat:
Custom
FullDateTime
LongDate
LongTime
MonthDay
RFC1123
ShortDate
ShortTime
SortableDateTime
UniversalSortableDateTime
YearMonth