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

10 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.

  2. This works perfect but date it shown with time so How to remove 12:00:00Am from the date picker text eg; 12/03/18 12:00;00 AM

  3. Thanks for sharing it!
    In case someone has the same issue I had: I changed the placeholder to “\”Select…\”” with the extra escaped quote chars to make it display the text properly.

  4. in case anyone needs any assistance with customizations dependent on platform, or how to display a true empty string on clear instead of /,/./ feel free to message me. great control.