CrossGeeks / ClearableDatePickerSample

Clearable DatePicker Sample in Xamarin Forms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to set Maximum and Minimum dates?

SatyaRamprasad opened this issue · comments

How to set Maximum and Minimum dates?

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