From 7006dcd1c7a0e958e5cd8be00ccbd8ec39ab8160 Mon Sep 17 00:00:00 2001 From: Jan Karger Date: Fri, 7 Dec 2018 13:05:10 +0100 Subject: [PATCH] (GH-3286) Fix for: DateTimePicker: Calendar.SelectedDate not always updated and consistent Closes #3286 --- src/MahApps.Metro/Controls/TimePicker/DateTimePicker.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/MahApps.Metro/Controls/TimePicker/DateTimePicker.cs b/src/MahApps.Metro/Controls/TimePicker/DateTimePicker.cs index 34277f522c..a5c4a1fda9 100644 --- a/src/MahApps.Metro/Controls/TimePicker/DateTimePicker.cs +++ b/src/MahApps.Metro/Controls/TimePicker/DateTimePicker.cs @@ -140,6 +140,7 @@ protected override void ApplyBindings() if (_calendar != null) { + _calendar.SetBinding(Calendar.SelectedDateProperty, GetBinding(SelectedDateTimeProperty)); _calendar.SetBinding(Calendar.DisplayDateProperty, GetBinding(DisplayDateProperty)); _calendar.SetBinding(Calendar.DisplayDateStartProperty, GetBinding(DisplayDateStartProperty)); _calendar.SetBinding(Calendar.DisplayDateEndProperty, GetBinding(DisplayDateEndProperty)); @@ -270,7 +271,7 @@ private void SetDatePartValues() var dateTime = GetSelectedDateTimeFromGUI(); if (dateTime != null) { - DisplayDate = dateTime.Value > DateTime.MinValue && dateTime.Value < DateTime.MaxValue ? dateTime.Value : DateTime.Today; + this.SetCurrentValue(DisplayDateProperty, dateTime.Value > DateTime.MinValue && dateTime.Value < DateTime.MaxValue ? dateTime.Value : DateTime.Today); if ((SelectedDateTime != DisplayDate && SelectedDateTime != DateTime.MinValue) || (Popup != null && Popup.IsOpen)) { this.SetCurrentValue(SelectedDateTimeProperty, DisplayDate);