Category / Section
How to create weekly recurrence appointments in WPF Scheduler (Calendar)
Add the weekly recurrence appointment to the SfScheduler with the help of RecurrenceRule.
Please refer to the user guide documentation for the recurrence property and its purpose.
C#
Create the recurrence appointment in the ViewModel with the help of RecurrenceRule.
public class SchedulerViewModel : INotifyPropertyChanged
{
private ScheduleAppointmentCollection scheduleAppointmentCollection;
public SchedulerViewModel()
{
this.ScheduleAppointmentCollection = new ScheduleAppointmentCollection();
var scheduleAppointment = new ScheduleAppointment()
{
Id = 1,
StartTime = DateTime.Today.AddHours(11),
EndTime = DateTime.Today.AddHours(12),
Subject = "Occurs weekly On Monday and Wednesday",
};
scheduleAppointment.RecurrenceRule = "FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE;COUNT=10";
ScheduleAppointmentCollection.Add(scheduleAppointment);
}
public ScheduleAppointmentCollection ScheduleAppointmentCollection
{
get
{
return this.scheduleAppointmentCollection;
}
set
{
this.scheduleAppointmentCollection = value;
this.RaiseOnPropertyChanged("ScheduleAppointmentCollection");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void RaiseOnPropertyChanged(string propertyName)
{
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
XAML
Binding ScheduleAppointmentCollection to Scheduler.
<syncfusion:SfScheduler x:Name="Schedule"
FirstDayOfWeek="Monday"
ViewType="Week"
ItemsSource="{Binding ScheduleAppointmentCollection}">
<syncfusion:SfScheduler.AppointmentMapping>
<syncfusion:AppointmentMapping StartTime="From"
EndTime="To"
Subject="EventName"
/>
</syncfusion:SfScheduler.AppointmentMapping>
</syncfusion:SfScheduler>
