DatePicker in DataGrid in WPF


Introduction

Date Picker is a control available in WPF Toolkit. In this article we would see how we can use DatePicker in DataGrid in WPF.

Crating WPF Application Project

Fire up Visual Studio 2008 and Create a WPF Application and name the project as DatePickerDGWPF.

WPFDate1.gif

Here is the basic idea of our sample application; we will have sample data with one or more datetime properties, which will be displayed in DataGrid.
When the DateTime cell will be in edit mode we will display the DatePicker in the cell instead of TextBox, which is by default.

So let's have a class and have sample data.

WPFDate2.gif

Now we will add a DataGrid to the Window and design the Columns inside of it.

WPFDate3.gif

It seems we are done with the design of our DataGrid columns.

Run the application and try to edit the column "Raised On", you would get DatePicker control to handle the Date and Time.

WPFDate4.gif

WPFDate5.gif

Hope this article helps.