5

Currently working on a Xamarin.Forms app where we need a blank value in DatePicker when the user did not select any date or when the form is loaded for the first time.

Here

DatePicker DO = new DatePicker();
DO.Format = "MM/dd/yyyy";

DO.Date = Convert.ToDateTime("01/01/1900");

we got this 01/01/1900 when the user did not select a date. But not the null or blank value in DatePicker field.

Not null value

TylerH
  • 20,799
  • 66
  • 75
  • 101
bipin
  • 51
  • 1
  • 4

1 Answers1

-5

Check below link it will be help you.Otherwise instead of DateTime collection take collection of String.

List<DateTimeString> dateCollection=new List<DateTimeString>();
dateCollection.add("")-- if required check null values and add.

https://www.dotnetperls.com/nullable-datetime

DateTime "null" value

Pratius Dubey
  • 673
  • 6
  • 19
  • 1
    Xamarin datepicker by default can't use a nullable datetime object. So TylerH will get a null reference exception if he makes the binding nullable. – Chris Jan 09 '19 at 20:21
  • First link is broken. Second link only shows how to get a null date in C# code, not in a Xamarin Form date picker control. – Savage Jun 02 '21 at 15:24