16

According to this post, there's a separate DatePicker control in .net 4. I've tried it, and I don't see a good way to also let it select the time of the day.

Is there an easy way to transform DatePicker into DateTimePicker by editing XAML template? If not, what is the best way to get a DateTimePicker for WPF 4.0?

4 Answers 4

34

Extended WPF Toolkit sports a nice DateTimePicker with time of day.

There is also an article over on CP where someone created a control that works like the Winforms one... A WPF DateTimePicker That Works Like the One in Winforms

2
  • 1
    That nice DateTimePicker keeps disappearing out of the namespace it's declared under in the XAML.
    – ProfK
    Commented Oct 8, 2014 at 18:04
  • Unfortunately, since version 4.0.0, it is only for non commercial use, unless buying a >600$ license. Commented Mar 16 at 0:34
10

There isn't one without making it yourself or using a 3rd party control. However there is one within winforms if you want a quick fix that doesn't support data binding...

xmlns:window="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"

<window:WindowsFormsHost >
    <wf:DateTimePicker Format="Time" ></wf:DateTimePicker>
</window:WindowsFormsHost>

Just a time picker, but could easily be paired with a datepicker. You also need a reference to WindowsFormsIntegration and System.Windows.Forms.

0
7

Try the DateTimePicker in the extended WPF toolkit.

6

If you do want an DateTimePicker without external controls and also for commercial use, I've improved an existing one and share it here: https://gist.github.com/Apflkuacha/406e755c8b42a70b7ab138e6b985bcdf

It will look like this, a field which shows the selected date&time and a popup window to select the date and time:

DateTimePicker

2
  • I keep getting "The resource InvertBoolConverter cannot be resolved". How do I make it find it? Commented Feb 21, 2022 at 16:24
  • I do have it in my shared resources, but I do have updated the gist to make clear how to define it. The converter itself is included in the code-behind file in the gist.
    – Coden
    Commented Feb 22, 2022 at 15:54

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.