See Also: DatePicker Members
The visual representation of a DatePicker is very similar to the one of Xamarin.Forms.Entry, except that a special control for picking a date appears in place of a keyboard.

The following example shows a basic use:
C# Example
using System;
using Xamarin.Forms;
namespace FormsGallery
{
class DatePickerDemoPage : ContentPage
{
public DatePickerDemoPage()
{
Label header = new Label
{
Text = "DatePicker",
Font = Font.BoldSystemFontOfSize(50),
HorizontalOptions = LayoutOptions.Center
};
DatePicker datePicker = new DatePicker
{
Format = "D",
VerticalOptions = LayoutOptions.CenterAndExpand
};
// Accomodate iPhone status bar.
this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
// Build the page.
this.Content = new StackLayout
{
Children =
{
header,
datePicker
}
};
}
}
}
The Xamarin.Forms.DatePicker class has the following XAML properties:
| Property | Value |
|---|---|
| Format | A string that specifies the display format in the control of the chosen date. |
| Date | An x:FactoryMethod call to the DateTime.Parse method, or a markup extension call to a method that produces a DateTime object. See below. |
| MinimumDate | An x:FactoryMethod call to the DateTime.Parse method, or a markup extension call to a method that produces a DateTime object. See below. |
| MaximumDate | An x:FactoryMethod call to the DateTime.Parse method, or a markup extension call to a method that produces a DateTime object. See below. |
The example below creates a working Xamarin.Forms.DatePicker that displays the current date and allows the user to select a date between the specified ranges. The value for the DatePicker.Date property is specified with the x:Static markup extension, and the DatePicker.MinimumDate and DatePicker.MaximumDate properties are specified by calling the DateTime.Parse method with the x:FactoryMethod and x:Arguments tags.
XAML Example
<StackLayout>
<DatePicker VerticalOptions="CenterAndExpand" Date="{x:Static sys:DateTime.Now}">
<DatePicker.Format>yyyy-MM-dd</DatePicker.Format>
<DatePicker.MinimumDate>
<sys:DateTime x:FactoryMethod="Parse">
<x:Arguments>
<x:String>Jan 1 2000</x:String>
</x:Arguments>
</sys:DateTime>
</DatePicker.MinimumDate>
<DatePicker.MaximumDate>
<sys:DateTime x:FactoryMethod="Parse">
<x:Arguments>
<x:String>Dec 31 2050</x:String>
</x:Arguments>
</sys:DateTime>
</DatePicker.MaximumDate>
</DatePicker>
</StackLayout>