DEV Community

Cover image for Recurring Events in .NET MAUI Scheduler—An Overview
Jollen Moyani for Syncfusion, Inc.

Posted on • Originally published at syncfusion.com on

Recurring Events in .NET MAUI Scheduler—An Overview

The .NET MAUI Scheduler is a tool for scheduling events in a .NET MAUI application. It supports scheduling recurring events, which are regularly or periodically occurring appointments or events. Scheduler’s API has been designed with simplicity and ease of use in mind, so that anyone can add recurring events to their project with just a few API calls. Supported by a robust internal scheduling engine, Scheduler gives you all the APIs you need to build simple and easy-to-maintain schedules.

Let’s see how to create and customize recurrence appointments in the .NET MAUI Scheduler.

Note: If you are new to this control, refer to the .NET MAUI Scheduler getting started documentation before proceeding.

Recurrence Rule

The Scheduler control uses the recurrence rule (string) to specify the recurrence details of an appointment. The recurrence rule specifies the recurrence frequency, interval, range, and position details.

Recurrence pattern

The pattern specifies the frequency or type of appointment: daily, weekly, monthly, and yearly.

Interval

Specify the interval between consecutive occurrences of the recurring appointment.

Range

The time range in which an appointment recurs. The range value is determined by the recurrence rule’s number of instances (count) or the end date (until). The recurring appointment is considered a never-ending appointment when the range is not specified.

Position details

The position (the day of the week, week of the month, month of the year) is specified and used on weekly, monthly, and yearly recurrence types.

Recurrence Types

Recurrence is the base term describing a repeating pattern. Business people use the concept of regular assignment of tasks or recurring events on certain days of the week, month, or even annually, like Jan. 1 every year.

Daily recurrence type

An appointment repeats daily with a specified day interval within a set date range. Following are some examples of daily recurrences.

Rule Description
FREQ=DAILY;INTERVAL=1;COUNT=5 Repeats the appointment for 5 consecutive days.
FREQ=DAILY;INTERVAL=1;UNTIL=20221225 Repeats the appointment every day until the specified end date.
FREQ=DAILY;INTERVAL=2 Repeats the appointment every 2 days with no end date.

Weekly recurrence type

An appointment repeats on a specified weekday with a specified week interval within the specified date range. Following are some examples of weekly recurrences.

Rule Description
FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE;COUNT=5 Repeats the appointment 5 times for specified weekdays (Monday, Wednesday) of every week.
FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE;UNTIL=20221225 Repeats the appointment on specified weekdays (Monday, Wednesday) of every week until the specified end date.
FREQ=WEEKLY;INTERVAL=2;BYDAY=MO,WE Repeats the appointment on specified weekdays (Monday, Wednesday) every 2 weeks with no end date.

Monthly recurrence type

An appointment repeats on a specified day of the month or weekday of a specified week position with a specified month interval within a set date range. Following are some examples of monthly recurrences.

Rule Description
FREQ=MONTHLY;BYMONTHDAY=3;INTERVAL=1;COUNT=5 Repeats the appointment 5 times on a specified day (3rd) of every month.
FREQ=MONTHLY;INTERVAL=1;BYDAY=MO;BYSETPOS=2;UNTIL=20221225 Repeats the appointment on a specified weekday (Monday) of a specified week (week 2) of every month until the specified end date.
FREQ=MONTHLY;INTERVAL=2;BYDAY=MO;BYSETPOS=2 Repeats the appointment on a specified weekday (Monday) of a specified week (week 2) every 2 months with no end date.

Yearly recurrence type

Schedule and repeat an appointment on a specified day of a month or weekday of specified week position of a month with a specified year interval within a specified date range.

Rule Description
FREQ=YEARLY;BYMONTHDAY=16;BYMONTH=6;INTERVAL=1;COUNT=5 Repeats the appointment 5 times for a specified day (16th) in the same month (June) of every year.
FREQ=YEARLY;BYDAY=SU;BYSETPOS=3;BYMONTH=8;INTERVAL=1;UNTIL=20251225 Repeats the appointment on a specified weekday (Sunday) of a specified week (week 3) in a specified month (August) for every year until the specified end date.
FREQ=YEARLY;BYDAY=SU;BYSETPOS=3;BYMONTH=8;INTERVAL=2; Repeats the appointment on a specified weekday (Sunday) of a specified week (week 3) in a specified month (August) every two years with no end date.

Example

SfScheduler scheduler = new SfScheduler();
scheduler.View = SchedulerView.Week;
var appointment = new ObservableCollection<SchedulerAppointment>();

//Adding scheduler appointment in the scheduler appointment collection.
appointment.Add(new SchedulerAppointment()
{
    StartTime = DateTime.Today.Date.AddHours(9),
    EndTime = DateTime.Today.Date.AddHours(11),
    Subject = "Daily scrum meeting",
    RecurrenceRule = "FREQ=DAILY;INTERVAL=1;COUNT=10"
});

//Adding the scheduler appointment collection to the AppointmentsSource of .NET MAUI Scheduler.
scheduler.AppointmentsSource = appointment;
this.Content = scheduler;
Enter fullscreen mode Exit fullscreen mode

Daily Recurrence Type in .NET MAUI Scheduler

Daily Recurrence Type in .NET MAUI Scheduler

Note: For more details, refer to the Recurrence appointments in the .NET MAUI Scheduler documentation.

Recurrence Exception Appointment

The Scheduler control provides support to restrict (change start time, end time, and appointment details) occurrences and remove an occurrence of a repeating appointment with a recurrence exception.

Deleting a recurring appointment

The RecurrenceExceptionDates property in an appointment is used to remove the occurrence on specified dates.

Refer to the following code example.

SfScheduler scheduler = new SfScheduler();
scheduler.View = SchedulerView.Week;
var appointment = new ObservableCollection<SchedulerAppointment>();

//Adding scheduler appointment in the scheduler appointment collection.
appointment.Add(new SchedulerAppointment()
{
    StartTime = DateTime.Today.Date.AddHours(9),
    EndTime = DateTime.Today.Date.AddHours(11),
    Subject = "Daily scrum meeting",
    RecurrenceRule = "FREQ=DAILY;INTERVAL=1;COUNT=10",
    RecurrenceExceptionDates = new ObservableCollection<DateTime> { DateTime.Today.AddDays(1) },
});

//Adding the scheduler appointment collection to the AppointmentsSource of .NET MAUI Scheduler.
scheduler.AppointmentsSource = appointment;
this.Content = scheduler;
Enter fullscreen mode Exit fullscreen mode

Deleting an occurrence of a recurring appointment

Deleting an occurrence of a recurring appointment

Modifying an occurrence of an appointment

The RecurrenceExceptionDates and RecurrenceId properties in an appointment are used to change the occurrence appointment details without removing the appointment on a specified date.

Refer to the following code example.

SfScheduler scheduler = new SfScheduler();
scheduler.View = SchedulerView.Week;
var appointment = new ObservableCollection<SchedulerAppointment>();

//Adding scheduler appointment in the scheduler appointment collection.
appointment.Add(new SchedulerAppointment()
{
     Id = 1,
     StartTime = DateTime.Today.Date.AddHours(9),
     EndTime = DateTime.Today.Date.AddHours(11),
     Subject = "Daily scrum meeting",
     RecurrenceRule = "FREQ=DAILY;INTERVAL=1;COUNT=10",
     RecurrenceExceptionDates = new ObservableCollection<DateTime> { DateTime.Today.AddDays(1) },
});

//Adding exception appointment in the scheduler appointment collection.
Appointment.Add(new SchedulerAppointment()
{
     Id = 2,
     StartTime = DateTime.Today.AddDays(1).Date.AddHours(11),
     EndTime = DateTime.Today.AddDays(1).Date.AddHours(13),
     Subject = "Scrum meeting - Changed",
     RecurrenceId=1,
});

//Adding the scheduler appointment collection to the AppointmentsSource of .NET MAUI Scheduler.
scheduler.AppointmentsSource = appointment;
this.Content = scheduler;
Enter fullscreen mode Exit fullscreen mode

Modified an occurrence of a recurring appointment on a Scheduler

Modified an occurrence of a recurring appointment on a Scheduler

Conclusion

Thank you for your time! This blog post showed how to set a recurring appointment in the .NET MAUI Scheduler. You can explore other features in the Scheduler control in the documentation, where you can find detailed explanations of each with code examples.

If you are not a Syncfusion customer, you can try our 30-day free trial to see how our components can enhance your projects.

Please feel free to try out the samples available in our .NET MAUI sample location and share your feedback or ask questions in the comments section. Or contact us through our support forum, support portal, or feedback portal. We are happy to assist you!

Related blogs

Latest comments (0)