From e967c1882b47792a851288996302066a13491cad Mon Sep 17 00:00:00 2001 From: kronic Date: Wed, 20 Feb 2019 08:53:42 +0300 Subject: [PATCH] Fix https://github.com/MahApps/MahApps.Metro/issues/3455 --- src/MahApps.Metro/Controls/TimePicker/DateTimePicker.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MahApps.Metro/Controls/TimePicker/DateTimePicker.cs b/src/MahApps.Metro/Controls/TimePicker/DateTimePicker.cs index a5c4a1fda9..906f22ea49 100644 --- a/src/MahApps.Metro/Controls/TimePicker/DateTimePicker.cs +++ b/src/MahApps.Metro/Controls/TimePicker/DateTimePicker.cs @@ -238,7 +238,7 @@ private static void OnSelectedDateChanged(object sender, SelectionChangedEventAr */ dateTimePicker._deactivateWriteValueToTextBox = true; - var dt = (DateTime?)e.AddedItems[0]; + var dt = e.AddedItems.Count > 0 ? (DateTime?)e.AddedItems[0] : default; if (dt.HasValue) { dateTimePicker.SetCurrentValue(SelectedDateTimeProperty, dt.Value.Date + dateTimePicker.GetSelectedTimeFromGUI()); @@ -279,4 +279,4 @@ private void SetDatePartValues() } } } -} \ No newline at end of file +}