WPF DatePicker Control
A DatePicker control is used to create a visual DatePicker that let user to pick a date and fire an event on theselection of the date. This article demonstrates how to create and use a DatePicker control in WPF with the help of XAML and C#.
Creating a DatePicker
The DatePicker element represents a WPF DatePicker control in XAML.
The DatePicker control is defined in the System.Windows.Controls namespace. When you drag and drop aDatePicker control from Toolbox to the page, you will notice the code listed in Listing 1 is added to the XAML filefor the DatePicker control.
Name="datePicker1" VerticalAlignment="Top"Width="115" />
The Width and Height attributes of the DatePicker element represent the width and the height of a DatePicker. TheContent attribute represents the text of a DatePicker. The Name attribute represents the name of the control, whichis a unique identifier of a control.When you run this code, you will see a TextBox with text Select a date and when you click on this TextBox or thedate, Calendar dropdown will appear where you can select a date. The selected date will be the date in the TextBoxas you can see in Figure 1.