I would like to make the calendar show particular month and I would like to define range of allowed dates in calendar
DateTime today = DateTime.Today;
DatePickerDialog dateDialog = new DatePickerDialog(this, this.OnToDateSet, today.Year, today.Month - 1, today.Day);
dateDialog.DatePicker.MaxDate = DateTime.Today.Millisecond;
dateDialog.DatePicker.MinDate = new DateTime(today.Year, today.Month - 2, today.Day).Millisecond;
dateDialog.Show();
this is what I get in return ... it shows the wrong year & month when it appears
if I comment out maxdate and mindate then calendar opens at right year and month
Somebody please clarify
If you debug your codes, you will find
DateTime.Today.Millisecond
andnew DateTime(today.Year, today.Month - 2, today.Day).Millisecond
returns 0. This is where things went wrong. In Xamarin, if you want to get the Millisecond, you need to do a DateTime offset: