protected override void OnPropertyChanged(string propertyName = null) { base.OnPropertyChanged(propertyName); if (propertyName == SelectedDateProperty.PropertyName) { if (SelectedDate == null) { cDateEntry.Text = null; cDateEntry.Placeholder = NoDatePlaceholder; } else { cDatePicker.Date = SelectedDate.GetValueOrDefault(); cDateEntry.Text = SelectedDate.GetValueOrDefault().ToString(DateFormat); } } else if (propertyName == NoDatePlaceholderProperty.PropertyName) { cDateEntry.Placeholder = NoDatePlaceholder; } else if (propertyName == ClearDateTextProperty.PropertyName) { cClearDateButton.Text = ClearDateText; } else if (propertyName == IsDateNullableProperty.PropertyName) { if (!IsDateNullable) { cClearDateButton.IsEnabled = false; cClearDateButton.IsVisible = false; } } }
private TimeSpan GetTimeOfDay() { if (_timeOfDayChanged || !_timeOfDay.HasValue) { if (IsValueSelected(_hourInput) && IsValueSelected(_minuteInput) && IsValueSelected(_secondInput)) { var hours = (int)_hourInput.SelectedItem; var minutes = (int)_minuteInput.SelectedItem; var seconds = (int)_secondInput.SelectedItem; hours += GetAmPmOffset(hours); _timeOfDay = new TimeSpan(hours, minutes, seconds); } else { _timeOfDay = SelectedDate.GetValueOrDefault(DateTime.Today).TimeOfDay; } _timeOfDayChanged = false; } return(_timeOfDay.Value); }
private DateTime GetCorrectDateTime() { return(SelectedDate.GetValueOrDefault(DateTime.Today).Date + GetTimeOfDay()); }