i want to add som reccurring appointments to an SfSchedule Control, it accept the dirst appointment that i put in it, but when i want to add a second one it gives me a null reference exception.
this is my code:
var appointment = ((Horarios.BindingClass) DataContext).Appointment as ScheduleAppointment ??
new ScheduleAppointment();
RecurrenceProperties RecProp = new RecurrenceProperties
{
RecurrenceType = RecurrenceType.Weekly,
IsRangeRecurrenceCount = false,
IsRangeNoEndDate = true,
IsRangeEndDate = false,
};
switch (((Horarios.BindingClass)DataContext).CurrentSelectedDate.Value.DayOfWeek)
{
case DayOfWeek.Sunday:
break;
case DayOfWeek.Monday:
RecProp.IsWeeklyMonday = true;
break;
case DayOfWeek.Tuesday:
RecProp.IsWeeklyTuesday = true;
break;
case DayOfWeek.Wednesday:
RecProp.IsWeeklyWednesday = true;
break;
case DayOfWeek.Thursday:
RecProp.IsWeeklyThursday = true;
break;
case DayOfWeek.Friday:
RecProp.IsWeeklyFriday = true;
break;
case DayOfWeek.Saturday:
RecProp.IsWeeklySaturday = true;
break;
default:
throw new ArgumentOutOfRangeException();
}
appointment.StartTime = StartTime.DateTime.Value;
appointment.EndTime = EndTime.DateTime.Value;
appointment.RecurrenceRule = ScheduleHelper.RRuleGenerator(RecProp,
appointment.StartTime, appointment.EndTime);
appointment.IsRecursive = false;
EditorPage.Schedule.Appointments.Add(appointment);
i always get a null reference exception on the last line when i'm addin a second appointment, does not matter if it is a recurrent appointment or not.