void UpdateDateVisibility() { DatePicker.Superview.Hidden = !(QuestionnaireViewModel.Selection == QuestionaireSelection.YesSince); if (QuestionnaireViewModel.Selection == QuestionaireSelection.YesSince) { DateTime valueToShow = QuestionnaireViewModel.DateHasBeenSet ? QuestionnaireViewModel.GetLocalSelectedDate() : DateTime.Now.Date; _viewModel.SetSelectedDateUTC(valueToShow); // Set the default date value when user enter pick date mode UpdateDateLbl(QuestionnaireViewModel.DateLabel); } }
private void ShowDatePickerDialog() { DateTime previousSelection = GetLocalSelectedDate(); int day = DateHasBeenSet ? previousSelection.Day : DateTime.Now.Day; int month = DateHasBeenSet ? previousSelection.Month - 1 : DateTime.Now.Month - 1; // DatePicker uses 0-based month indexing, DateTime does not. int year = DateHasBeenSet ? previousSelection.Year : DateTime.Now.Year; _datePicker = new DatePickerDialog(Current.Activity, ((sender, args) => { _questionnaireViewModel.SetSelectedDateUTC(args.Date.ToUniversalTime()); _firstRadioButton.Checked = true; _firstRadioButton.ContentDescriptionFormatted = GetFormattedText; _datePickerTextView.Text = DateLabel; _datePickerTextView.Ellipsize = TextUtils.TruncateAt.End; }), year, month, day); _datePicker.DatePicker.MinDate = DateTimeToAndroidDatePickerLong(_questionnaireViewModel.MinimumDate.ToLocalTime()); _datePicker.DatePicker.MaxDate = DateTimeToAndroidDatePickerLong(DateTime.Now); _datePicker.Show(); }