public void PopulateDay() { if (_dayItems != null) { _dayItems.Children.Clear(); DateTime startTime = new DateTime(CurrentDate.Year, CurrentDate.Month, CurrentDate.Day, 0, 0, 0); for (int i = 0; i < 48; i++) { CalendarTimeslotItem timeslot = new CalendarTimeslotItem(Owner); timeslot.StartTime = startTime; timeslot.EndTime = startTime + TimeSpan.FromMinutes(30); SetTimeslotBackground(timeslot, startTime.Hour); timeslot.SetBinding(CalendarTimeslotItem.StyleProperty, GetOwnerBinding("CalendarTimeslotItemStyle")); _dayItems.Children.Add(timeslot); startTime = startTime + TimeSpan.FromMinutes(30); } } if (Owner != null) { Owner.ScrollToHome(); } }
public void SetTimeslotBackground(CalendarTimeslotItem timeslot, int startHour) { if (!Owner.ShowOffPeekHours || (startHour >= Owner.PeekStartHour && startHour <= Owner.PeekEndHour)) { timeslot.SetBinding(Calendar.BackgroundProperty, GetOwnerBinding("PeakTimeslotBackground")); } else { timeslot.SetBinding(Calendar.BackgroundProperty, GetOwnerBinding("OffPeakTimeslotBackground")); } }