public CalendarDatePickerRenderer( global::Android.Content.Context context, CalendarDatePicker datePicker) : base(context, datePicker) { this._nativeDateView = new AndroidDateView(context) { Focusable = false, FocusableInTouchMode = false, Clickable = true, LongClickable = false, }; this._nativeDateView.SetCursorVisible(false); #if DEBUG_LAYOUT this._nativeDateView.SetTextColor(global::Android.Graphics.Color.DarkGreen); #endif this._nativeDateView.Click += NativeDateView_Click; DateTime selectedDate = DateTime.Now.Date; this._nativeDatePickerDialog = new AndroidDatePickerDialog( context, new DatePickerCallback(this), selectedDate.Year, selectedDate.Month, selectedDate.Day); { }; this._nativeDatePickerDialog.DatePicker.FirstDayOfWeek = Calendar.Monday; this.SetNativeElement(this._nativeDateView); }
/// <inheritdoc /> public Task <DateTime?> DisplayDatePickerAsync( string title = null, string message = null, string actionButton = null, string cancelButton = null, DateTime?initialDate = null, DateTime?minDate = null, DateTime?maxDate = null) { var tcs = new TaskCompletionSource <DateTime?>(); MainApplication.CurrentActivity.RunOnUiThread(() => { var dateDialog = new global::Android.App.DatePickerDialog(MainApplication.CurrentActivity); dateDialog.SetCancelable(false); dateDialog.SetCanceledOnTouchOutside(false); if (minDate != null) { dateDialog.DatePicker.MinDate = minDate.Value.ToLongDate(); } if (maxDate != null) { dateDialog.DatePicker.MaxDate = maxDate.Value.ToLongDate(); } if (initialDate != null) { dateDialog.DatePicker.DateTime = initialDate.Value; } if (title != null) { dateDialog.SetTitle(title); } if (message != null) { dateDialog.SetMessage(message); } dateDialog.SetButton( (int)DialogButtonType.Negative, cancelButton ?? "Cancel", delegate { tcs.TrySetResult(null); dateDialog.Hide(); } ); dateDialog.SetButton( (int)DialogButtonType.Positive, actionButton ?? "Ok", delegate { tcs.TrySetResult(dateDialog.DatePicker.DateTime); dateDialog.Hide(); } ); dateDialog.Show(); }); return(tcs.Task); }