private void PopulateWeek() { DaysOfWeek.Clear(); DayStrings.Clear(); for (int i = 0; i <= 6; i++) { DateTime dayOfWeek = StartOfWeek.AddDays(i); DaysOfWeek.Add(dayOfWeek); DayStrings.Add(dayOfWeek.ToString("dd.MM.yyyy")); DayNotEmpty[i] = false; } OnPropertyChanged("DayStrings"); MondayAppointments = new ObservableCollection <Appointment>(); TuesdayAppointments = new ObservableCollection <Appointment>(); WednesdayAppointments = new ObservableCollection <Appointment>(); ThursdayAppointments = new ObservableCollection <Appointment>(); FridayAppointments = new ObservableCollection <Appointment>(); SaturdayAppointments = new ObservableCollection <Appointment>(); SundayAppointments = new ObservableCollection <Appointment>(); foreach (Appointment a in AppointmentsDB.Instance.Appointments) { if (a.StartTime.Date == DaysOfWeek[0].Date) { MondayAppointments.Add(a); DayNotEmpty[0] = true; } else if (a.StartTime.Date == DaysOfWeek[1].Date) { TuesdayAppointments.Add(a); DayNotEmpty[1] = true; } else if (a.StartTime.Date == DaysOfWeek[2].Date) { WednesdayAppointments.Add(a); DayNotEmpty[2] = true; } else if (a.StartTime.Date == DaysOfWeek[3].Date) { ThursdayAppointments.Add(a); DayNotEmpty[3] = true; } else if (a.StartTime.Date == DaysOfWeek[4].Date) { FridayAppointments.Add(a); DayNotEmpty[4] = true; } else if (a.StartTime.Date == DaysOfWeek[5].Date) { SaturdayAppointments.Add(a); DayNotEmpty[5] = true; } else if (a.StartTime.Date == DaysOfWeek[6].Date) { SundayAppointments.Add(a); DayNotEmpty[6] = true; } OnPropertyChanged("SundayAppointments"); OnPropertyChanged("SaturdayAppointments"); OnPropertyChanged("FridayAppointments"); OnPropertyChanged("ThursdayAppointments"); OnPropertyChanged("WednesdayAppointments"); OnPropertyChanged("TuesdayAppointments"); OnPropertyChanged("MondayAppointments"); OnPropertyChanged("DayNotEmpty"); } }