Skip to content

Commit

Permalink
Merge pull request #3456 from kronic/develop
Browse files Browse the repository at this point in the history
Fix for DateTimePicker System.IndexOutOfRangeException #3455
  • Loading branch information
punker76 authored Feb 22, 2019
2 parents 288c4fe + e967c18 commit b70546b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/MahApps.Metro/Controls/TimePicker/DateTimePicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -279,4 +279,4 @@ private void SetDatePartValues()
}
}
}
}
}

0 comments on commit b70546b

Please # to comment.