CrossGeeks / ClearableDatePickerSample

Clearable DatePicker Sample in Xamarin Forms
MIT License
19 stars 11 forks source link

How to set Maximum and Minimum dates? #7

Open SatyaRamprasad opened 6 years ago

oscarjaergren commented 5 years ago

Add this to the method below

private void ShowDatePicker() { CreateDatePickerDialog(this.Element.Date.Year, this.Element.Date.Month - 1, this.Element.Date.Day);

        Calendar cal = new GregorianCalendar();
        cal.Set(Element.MaximumDate.Year, Element.MaximumDate.Month, Element.MaximumDate.Day);

        Date dateRepresentation = cal.Time;

        _dialog.DatePicker.MaxDate = dateRepresentation.Time;

        _dialog.Show();
    }

I.e only important is the _dialog.DatePicker.MaxDate BUT it won't work unless the date is in java date time

Do same for DatePicker.MinDate and it will work