Skip to content

Commit

Permalink
[Fix] Issue when the time is cleared if a date is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelmairegger committed Feb 3, 2017
1 parent 324adee commit 81d2d20
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ protected override void ApplyBindings()
_calendar.SetBinding(Calendar.FirstDayOfWeekProperty, GetBinding(FirstDayOfWeekProperty));
_calendar.SetBinding(Calendar.IsTodayHighlightedProperty, GetBinding(IsTodayHighlightedProperty));
_calendar.SetBinding(FlowDirectionProperty, GetBinding(FlowDirectionProperty));
_calendar.SetBinding(Calendar.SelectedDateProperty, GetBinding(SelectedDateProperty));
_calendar.SelectedDatesChanged += OnCalendarSelectedDateChanged;
}
}

Expand Down Expand Up @@ -210,6 +210,19 @@ protected override void WriteValueToTextBox()
}
}

private void OnCalendarSelectedDateChanged(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0)
{
var dt = (DateTime)e.AddedItems[0];

var timeOfDay = SelectedDate.GetValueOrDefault().TimeOfDay;

dt += timeOfDay;
SelectedDate = dt;
}
}

private static object CoerceOrientation(DependencyObject d, object basevalue)
{
if (((DateTimePicker)d).IsClockVisible)
Expand Down

0 comments on commit 81d2d20

Please sign in to comment.