//LoadItems comes from Parent Class public override ObservableCollection <CustomDay> LoadItems() { { CustomMonth cm = MonthHelper.CreateMonth(DateTime.Now); ObservableCollection <CustomDay> dayList = new ObservableCollection <CustomDay>(); foreach (var item in cm.Days) { dayList.Add(item); } CustomMonthList.Add(cm); return(dayList); } }
//Add a month to the current date and refresh the displayed calendar private void Next() { SessionManager.CurrentDate = SessionManager.CurrentDate.AddMonths(1); CustomMonth cm = (customMonthList.Where(x => x.Month == SessionManager.CurrentDate.Month && x.Year == SessionManager.CurrentDate.Year).FirstOrDefault()); if (cm == null) { cm = MonthHelper.CreateMonth(SessionManager.CurrentDate); } ObservableCollection <CustomDay> dayList = new ObservableCollection <CustomDay>(); foreach (var item in cm.Days) { dayList.Add(item); } Items = dayList; //RaisePropertyChanged is here to update the label along with the dates themselves RaisePropertyChanged(nameof(Month)); RaisePropertyChanged(nameof(Year)); dayList.Where(x => x.DayInMonth == 1).FirstOrDefault().SelectedEvent.Invoke(this, EventArgs.Empty); CustomMonthList.Add(cm); }