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 +}