The DatePicker is a control that is part of the Silverlight Toolkit for Windows Phone .
The DatePicker control includes a TextBox and Date Selection form .
When the user taps on the TextBox , a form to select the date , month and year is shown and on the click of the OK icon in the Application Bar of the Date Selection form , the textbox will be filled with the selected date.
DatePicker in Silverlight Toolkit
To add the DatePicker control in the Silverlight Toolkit , just drag and drop the DatePicker control from the Visual Studio Toolbox . Make sure that you have installed the silverlight toolkit and have included the controls to the Visual Studio Toolbox .
If you are trying to create the DatePicker control dynamically , you should add the reference of the Microsoft.Phone.Controls.Toolkit.dll to your Windows Phone App .
The XAML code of the DatePicker control will look like this
<toolkit:DatePicker Height="74" HorizontalAlignment="Left" Margin="25,214,0,0" Name="datePicker1" VerticalAlignment="Top" Width="406" />
You can add the DatePicker control dynamically from the codebehind .
1. Add the name space Microsoft.Phone.Controls
2. Create an instance of the DatePicker control and add it to the container / panel
DatePicker picker = new DatePicker(); ContentPanel.Children.Add(picker);
3. Run the Windows Phone App , you should see a textbox , tap on it to select the date …
4. The selected date can be found via the Value or ValueString property of the DatePicker control