Clearable DatePicker in Xamarin Forms

When using date pickers, sometimes we have the need to be able to set no value at all. For that just created a control to a support nullable date value but also provide the possibility to clear it.

Using it is really simple, let’s do it step by step:

1-In your Forms project add this control

In the code above created a new property called NullableDate, we are going to use this property instead of the Date Property.

2-In the Android project add this NullableDatePickerRenderer

3-In the iOS project add this NullableDatePickerRenderer

4-Use the control

As you can see here instead of using the Date property you will use a new property called NullableDate. 

Also, if you want to change the default placeholder empty value you can do it by using the PlaceHolder property.

You can see the full source code used here:

https://github.com/CrossGeeks/ClearableDatePickerSample

Happy coding! 🙂

You may also like

2 Comments

  1. How did you create spinner mode for your datepicker in droid project?
    What version of android are you running on ?
    I tried on my note5 running in Android 7.0 API 24 and Samsung Tablet E running in Android 6.0 API 23, all I get is calendar mode for datepicker.