This article demonstrates the use of a DatePicker control in Windows Phone 7. By default the DatePicker shows today's date; when the control is clicked a dialog should open for selecting day, month and year; then after clicking done, the selected date should load into the control.
Steps to do:
- First of make a new Silverlight Windows Phone project and save given location
- Now (if not yet done) download the Windows Phone 7 toolkit from the Codeplex website and save in your hard drive.
- Add a reference to Microsoft.Phone.Controls.Toolkit.dll in your application like image 1.
Now add a namespace on .xaml page or add this Microsoft.Phone.Controls.Toolkit.dll in toolbox when drag and drop control on page this namespace should add automatically.
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
<toolkit:DatePicker HorizontalAlignment="Left" Margin="149,219,0,0"
Name="txtPostedOn" VerticalAlignment="Top" Width="325"
Height="55" FontFamily="Verdana"
FontSize="13.333" Foreground="#FFDA4D4D" />
![img1.jpg](https://www.csharp.com/UploadFile/raj1979/windows-phone-7-datepicker-control/Images/img1.jpg)
Image 1.
![img2.jpg](https://www.csharp.com/UploadFile/raj1979/windows-phone-7-datepicker-control/Images/img2.jpg)
Image 2.
After adding control on page it looks like this. When click on control this window should open.
![IMG3.jpg](https://www.csharp.com/UploadFile/raj1979/windows-phone-7-datepicker-control/Images/IMG3.jpg)
Image 3.
Here you can select Month, Day and year by clicking on these rectangles like this. You can scroll top and bottom.
Note - These cross icon images shows left one is for done and right icon for cancel.
![IMG4.jpg](https://www.csharp.com/UploadFile/raj1979/windows-phone-7-datepicker-control/Images/IMG4.jpg)
Image 4.
When you are done with this click on the Done icon.
![IMG5.jpg](https://www.csharp.com/UploadFile/raj1979/windows-phone-7-datepicker-control/Images/IMG5.jpg)
Image 5.