Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DateTimePicker for WPF 4.0

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?

like image 466
Arsen Zahray Avatar asked May 18 '12 19:05

Arsen Zahray


People also ask

How to add date time picker in WPF?

Creating a DateTimePicker The DateTimePicker control is defined in the System. Windows. Controls namespace. When you drag and drop a DateTimePicker control from Toolbox to the page, you will notice the code listed in Listing 1 is added to the XAML file for the DateTimePicker control.

How do I add a DatePicker to XAML?

Drag a DatePicker from the toolbox. The following example shows how to create a DatePicker control. When you click on any date from the DatePicker control, the program will update the title with that date. The following XAML code creates a DatePicker with some properties and click event.

Which control is used as a DatePicker?

The DatePicker control allows the user to select a date by either typing it into a text field or by using a drop-down Calendar control. Many of a DatePicker control's properties are for managing its built-in Calendar, and function identically to the equivalent property in Calendar. In particular, the DatePicker.


2 Answers

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

like image 51
Dean Kuga Avatar answered Sep 28 '22 11:09

Dean Kuga


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.

like image 36
Kevin DiTraglia Avatar answered Sep 28 '22 09:09

Kevin DiTraglia