The WPF Scheduler is used to schedule day-to-day appointments, and it also makes it easy to maintain repeating appointments such as anniversaries, birthdays, or meetings that occur on different dates at the same time.
In this blog post, we’ll see how to easily create and manage repeating appointments using the WPF Scheduler control.
Note: If you are new to our Scheduler control, please read the Getting Started with WPF Scheduler documentation before proceeding.
Let’s look at the different recurrence patterns!
Recurrence pattern
The recurrence pattern rule contains the following details which are used to create the repeating or recurring appointment:
- Recurrence Frequency: Specifies the repeat type as daily, weekly, monthly, or yearly.
- Recurrence Interval: Specifies the time interval between the recurring appointments.
- Recurrence End Range: The recurrence end range is based on a specific end date or the number of occurrences.
Daily recurrence pattern
The daily recurrence pattern is used to create events that occur every day and at the same time.
Examples:
//Daily recurrence pattern with count. FREQ=DAILY;INTERVAL=1;COUNT=5 //Daily recurrence pattern with end date. FREQ=DAILY;INTERVAL=1;UNTIL=20200725 //Daily recurrence pattern with no end date. FREQ=DAILY;INTERVAL=2;
Weekly recurring pattern
The weekly recurrence pattern is used to create events that occur on certain days on every week.
Examples:
//Weekly recurrence pattern with count and day of week. FREQ=WEEKLY;INTERVAL=2;BYDAY=WE;COUNT=20 //Weekly recurrence pattern with end date and day of week. FREQ=WEEKLY;INTERVAL=1;BYDAY=TU,FR;UNTIL=20200811 //Weekly recurrence pattern with no end date. FREQ=WEEKLY;INTERVAL=2;BYDAY=MO,WE;
Monthly recurring pattern
The monthly recurrence pattern is used to create recurring events that occur on a certain day of a month or a certain day of a week every month.
Examples:
//Monthly recurrence pattern with count and day of the month. FREQ=MONTHLY;BYMONTHDAY=3;INTERVAL=1;COUNT=10 //Monthly recurrence pattern with end date, day of week, and week position. FREQ=MONTHLY;INTERVAL=1;BYDAY=MO;BYSETPOS=2;UNTIL=20200725 // Monthly recurrence pattern with no end date. FREQ=MONTHLY;BYMONTHDAY=3;INTERVAL=2;
Yearly recurring pattern
The yearly recurrence pattern is used to create recurring events that occur on a certain day of the month or a certain day of a week in the month that repeat every year.
Examples:
//Yearly recurrence pattern with month, day of the month, and end date. FREQ=YEARLY;BYMONTHDAY=15;BYMONTH=5;INTERVAL=1; UNTIL=20230618 //Yearly recurrence pattern with count, month and week day and week position. FREQ=YEARLY;BYDAY=TH;BYSETPOS=2;BYMONTH=6;INTERVAL=1;COUNT=10 //Yearly recurrence pattern with no end date. FREQ=YEARLY;BYDAY=SU;BYSETPOS=3;BYMONTH=8;INTERVAL=2;
How to create recurring appointments in WPF Scheduler
Follow these steps to create repeating appointments in the WPF Scheduler:
- First, initialize the Syncfusion WPF Scheduler control.
xmlns:scheduler="using:Syncfusion.UI.Xaml.Scheduler" <syncfusion:SfScheduler x:Name="Schedule" ViewType="Week" ItemsSource="{Binding AppointmentCollection}"> </syncfusion:SfScheduler>
- Then, create repeating events with the recurrence rule and add them to the Scheduler’s ItemsSource.
// Creating an instance for the Scheduler appointment collection. var appointmentCollection = new ScheduleAppointmentCollection(); //Adding schedule appointment in appointment collection. var scheduleAppointment = new ScheduleAppointment() { Id = 1, StartTime = new DateTime(2022, 3, 20, 11, 0, 0), EndTime = new DateTime(2022, 3, 20, 12, 0, 0), Subject = "Occurs every alternate day", AppointmentBackground = Brushes.RoyalBlue, Foreground = Brushes.White, }; //Creating the recurrence rule. scheduleAppointment.RecurrenceRule = "FREQ=DAILY;INTERVAL=2;COUNT=10"; //Adding schedule appointment to the appointment collection. appointmentCollection.Add(scheduleAppointment); //Setting the appointment collection to the ItemsSource of the SfScheduler. Schedule.ItemsSource = appointmentCollection;
Note: To learn more, refer to the recurring appointments in the WPF Scheduler demo.
Create recurrence exception appointment
It is also possible to remove or reschedule the event time of a specific occurrence of a recurring appointment.
For example, you can easily reschedule or delete an appointment from the series that occurs on a holiday.
To do so, we have to create recurrence exception appointments using the RecurrenceExceptionDates property in the ScheduleAppointment class.
Refer to the following code to remove the occurrence of any appointment on specific dates.
// Creating an instance for appointment collection. var appointmentCollection = new ScheduleAppointmentCollection(); // Recurrence and exception appointments. var scheduleAppointment = new ScheduleAppointment { Id = 1, Subject = "Daily scrum meeting", StartTime = new DateTime(2022, 3, 20, 11, 0, 0), EndTime = new DateTime(2022, 3, 20, 12, 0, 0), AppointmentBackground = new SolidColorBrush(Colors.RoyalBlue), Foreground = new SolidColorBrush(Colors.White), RecurrenceRule = "FREQ=DAILY;INTERVAL=1;COUNT=10" }; //Adding the recurring appointment to the appointmentcollection. appointmentCollection.Add(scheduleAppointment); //Add the ExceptionDates to avoid occurrence on specific dates. DateTime exceptionDate = scheduleAppointment.StartTime.AddDays(3).Date; scheduleAppointment.RecurrenceExceptionDates = new ObservableCollection<DateTime>() { exceptionDate, }; //Setting appointmentCollection as ItemsSource of SfScheduler. Schedule.ItemsSource = appointmentCollection;
Refer to the following code to reschedule recurring appointments.
// Creating an instance for appointment collection. var appointmentCollection = new ScheduleAppointmentCollection(); // Recurrence and exception appointment. var scheduleAppointment = new ScheduleAppointment { Id = 1, Subject = "Daily scrum meeting", StartTime = new DateTime(2022, 3, 20, 11, 0, 0), EndTime = new DateTime(2022, 3, 20, 12, 0, 0), AppointmentBackground = new SolidColorBrush(Colors.RoyalBlue), Foreground = new SolidColorBrush(Colors.White), RecurrenceRule = "FREQ=DAILY;INTERVAL=1;COUNT=10" }; //Adding the recurring appointment to the appointmentCollection. appointmentCollection.Add(scheduleAppointment); //Add ExceptionDates to avoid occurrence on specific dates. DateTime changedExceptionDate = scheduleAppointment.StartTime.AddDays(3).Date; scheduleAppointment.RecurrenceExceptionDates = new ObservableCollection<DateTime>() { changedExceptionDate, }; //Creating an exception occurrence appointment by changing the start time or end time. // RecurrenceId is set to 1, so it will change the occurrence for the above-created pattern appointment. var exceptionAppointment = new ScheduleAppointment() { Id = 2, Subject = "Scrum meeting - Changed Occurrence", StartTime = new DateTime(changedExceptionDate.Year, changedExceptionDate.Month, changedExceptionDate.Day, 13, 0, 0), EndTime = new DateTime(changedExceptionDate.Year, changedExceptionDate.Month, changedExceptionDate.Day, 14, 0, 0), AppointmentBackground = new SolidColorBrush(Colors.DeepPink), Foreground = new SolidColorBrush(Colors.White), RecurrenceId = 1 }; // Adding an exception occurrence appointment to the appointmentCollection. appointmentCollection.Add(exceptionAppointment); //Setting the appointmentCollection as a ItemsSource of SfScheduler. Schedule.ItemsSource = appointmentCollection;
Note: To learn more, refer to the recursive exception appointments demo on GitHub.
Recurrence editor
Also, you can easily edit or delete a single or series of recurring appointments using the recurrence editor in the WPF Scheduler.
The following window will appear when we double-click on any recurring appointment to edit it.
The following window will appear when we delete a recurring appointment using the Delete key.
Conclusion
Thanks for reading! In this blog, we have seen how to easily create, edit, reschedule, and delete recurring appointments using the WPF Scheduler. Try out the steps provided in this blog post and enjoy hassle-free scheduling!
To find detailed explanations of each feature in the Scheduler control with code examples, refer to this documentation.
Please feel free to share your feedback or ask questions in the comments section below. You can also contact us through our support forum, support portal, or feedback portal. We are happy to assist you!
Related blogs
- Syncfusion Essential Studio® 2022 Volume 1 is Here!
- Display Alerts for Appointments in WPF Scheduler
- Load Appointments on Demand via Web Services in WPF Scheduler
- Easily Allocate Resources with the Resource View in WPF Scheduler