Copied RSS Feed

WinUI

Easily Schedule Recurring Events in WinUI Scheduler

In the Scheduler control, create events to schedule meetings and plan important tasks in your daily life. The scheduler control allows you to add appointments with details such as start and end times, subjects, and locations. You can also create recurring appointments.

A recurring or repeating appointment is a useful scheduling feature that allows you to create events that will appear at the same time on different dates. For example, a birthday event that will repeat every year on the same date.

In this blog post, we’ll look at how to use the WinUI Scheduler control to create recurring appointments.

Note: If you are new to our WinUI Scheduler control, then please read the Getting Started with WinUI Scheduler documentation before proceeding.

Before getting started, let’s look at the different recurrence patterns.

Recurrence patterns

The recurrence pattern specifies how frequently an event occurs. The event may occur on a daily, weekly, monthly, or yearly basis.

The following sections explain the different recurrence rules to be applied to specify the recurrence pattern.

Daily

The daily recurrence pattern is used to schedule daily repeated events, and occurrence repeated based on the interval.

Relevant properties:

  • FREQ—Repeat type of recurring appointment.
  • INTERVAL—Interval value of the recurring appointment.
  • COUNT—Count of the recurring appointments in the recurrence series.
  • UNTIL—End date of the recurring appointment series.

Example

  • Repeats daily with count or end range.
    //Daily recurrence with count.
    FREQ=DAILY;INTERVAL=1;COUNT=10
    //Daily recurrence with end date.
    FREQ=DAILY;INTERVAL=1;UNTIL=20200725
  • Repeats these events every two days with no end date.
    FREQ=DAILY;INTERVAL=2;

Weekly

The weekly recurrence pattern schedules weekly repeated events on the same days every week and the occurrence is repeated based on the interval.

Relevant properties:

  • FREQ—Repeat type of recurring appointment.
  • BYDAY—Day of the week of the recurring appointment.
  • INTERVAL—Interval value of the recurring appointment.
  • COUNT—Count of the recurring appointments in the recurrence series.
  • UNTIL—End date of the recurring appointment series.

Example

  • Repeats weekly with count or end range.
    //Weekly recurrence with count and day of week.
    FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE;COUNT=10
    //Weekly recurrence with end date and day of week.
    FREQ=WEEKLY;INTERVAL=1;BYDAY=TU;UNTIL=20210725
  • Repeats these events every two weeks once with no end date.
    FREQ=WEEKLY;INTERVAL=2;BYDAY=MO,WE;

Monthly

The monthly recurrence pattern schedules monthly repeated events on the same day of the month or the same week of the month and the occurrence is repeated based on the interval.

Relevant properties:

  • FREQ—Repeat type of recurring appointment.
  • INTERVAL—Interval value of the recurring appointment.
  • COUNT—Count of the recurring appointments in the recurrence series.
  • UNTIL—End date of the recurring appointment series.
  • BYMONTHDAY—Date of the month of the recurring appointment.
  • BYSETPOS—Week of the month of the recurring appointment.

Example

  • Repeats monthly with count or end range.
    //Monthly recurrence with count, month day.
    FREQ=MONTHLY;BYMONTHDAY=3;INTERVAL=1;COUNT=10
    //Monthly recurrence with end date, day of week and week position.
    FREQ=MONTHLY;INTERVAL=1;BYDAY=MO;BYSETPOS=2;UNTIL=20200725
  • Repeats these events once every two months with no end date.
    FREQ=MONTHLY;BYMONTHDAY=3;INTERVAL=2;

Yearly

The yearly recurrence pattern schedules yearly repeated events on the same day of the year or the same week of the year and the occurrence is repeated based on the interval.

Relevant properties:

  • FREQ—Repeat type of the recurring appointment.
  • INTERVAL—Interval value of the recurring appointment.
  • COUNT—Count of the recurring appointment in recurrence series.
  • UNTIL—End date of the recurring appointment series.
  • BYMONTHDAY—Date of month of the recurring appointment.
  • BYDAY—Day of week of the recurring appointment.
  • BYMONTH—Month of year of the recurring appointment.

Example

  • Repeats yearly with count or end range.
    //Yearly recurrence with count, month and week day.
    FREQ=YEARLY;BYDAY=SU;BYSETPOS=3;BYMONTH=8;INTERVAL=1;COUNT=10
    //Yearly recurrence with end date, month, and month day. 
    FREQ=YEARLY;BYMONTHDAY=16;BYMONTH=6;INTERVAL=1;UNTIL=20250725
  • Repeats these events every two years once with no end date.
    FREQ=YEARLY;BYDAY=SU;BYSETPOS=3;BYMONTH=8;INTERVAL=2;

Scheduling recurring appointments

Follow these steps to schedule recurring appointments:

  1. Initialize the Scheduler control.
    xmlns:scheduler="using:Syncfusion.UI.Xaml.Scheduler"
    <scheduler:SfScheduler x:Name="Schedule" 
                            ViewType="Week">
    </scheduler:SfScheduler>
  2. Use the ScheduleAppointment class to create events and add the events using the ItemsSource property of SfScheduler. Use the RecurrenceRule property of ScheduleAppointment to schedule the recurring events.
    Schedule.DisplayDate = new DateTime(2021, 3, 28, 11, 0, 0);
    // Creating an instance for schedule appointment collection.
    var appointmentCollection = new ScheduleAppointmentCollection();
    //Adding schedule appointment in the schedule appointment collection. 
    var scheduleAppointment = new ScheduleAppointment
    {
    //Id to recurrence pattern appointment.
        Id = 1,
        Subject = "Daily scrum meeting",
        StartTime = new DateTime(2021, 3, 28, 11, 0, 0),
        EndTime = new DateTime(2021, 3, 28, 12, 0, 0),
        AppointmentBackground = new SolidColorBrush(Color.FromArgb(255, 0, 120, 215)),
        Foreground = new SolidColorBrush(Colors.White),
    //Add recurrence rule to repeat the event.
        RecurrenceRule = "FREQ=DAILY;INTERVAL=1;COUNT=10"
    };
    //Adding the schedule appointment to the schedule appointment collection.
    appointmentCollection.Add(scheduleAppointment);
    //Adding the schedule appointment collection to the ItemsSource of SfScheduler.
    Schedule.ItemsSource = appointmentCollection;
Event Occurs Everyday

To learn more, refer to the recurring events in WinUI Scheduler demo.

Delete an appointment occurrence

The Scheduler control’s recurrence pattern exception feature allows you to remove a specific occurrence from a recurring appointment or change the details of any occurrence.

For example, you can delete any recurring appointment that falls on a holiday or modify any occurrence based on your availability on a specific day. The RecurrenceExceptionDates property of ScheduleAppointment is used to remove a specific occurrence of a recurring event.

Refer to the following code example for more details.

Schedule.DisplayDate = new DateTime(2021, 3, 28, 11, 0, 0);

// Creating an instance for schedule appointment collection.
var appointmentCollection = new ScheduleAppointmentCollection();
// Recurrence and exception appointment.
var scheduleAppointment = new ScheduleAppointment
{
    Id = 1,
    Subject = "Daily scrum meeting",
    StartTime = new DateTime(2021, 3, 28, 11, 0, 0),
    EndTime = new DateTime(2021, 3, 28, 12, 0, 0),
    AppointmentBackground = new SolidColorBrush(Color.FromArgb(255, 0, 120, 215)),
    Foreground = new SolidColorBrush(Colors.White),
    RecurrenceRule = "FREQ=DAILY;INTERVAL=1;COUNT=10"
};
//Adding the recurring or pattern appointment to the AppointmentCollection.
appointmentCollection.Add(scheduleAppointment);

//Add exception dates to avoid occurrence on specific dates.
DateTime changedExceptionDate = scheduleAppointment.StartTime.AddDays(3).Date;
scheduleAppointment.RecurrenceExceptionDates = new ObservableCollection<DateTime>()
{
    changedExceptionDate,
};

//Setting the AppointmentCollection as an ItemSource of SfScheduler.
this.Schedule.ItemsSource = appointmentCollection;
A Specific Occurrence Deleted in a Recurring Event

Recurrence exception appointment

You can modify any particular occurrence of a recurring appointment by using the RecurrenceExceptionDates and RecurrenceId properties of ScheduleAppointment.

Refer to the following code example for more details.

Schedule.DisplayDate = new DateTime(2021, 3, 28, 11, 0, 0);

// Creating an instance for schedule appointment collection.
Var appointmentCollection = new ScheduleAppointmentCollection();
// Recurrence and exception appointment.
Var scheduleAppointment = new ScheduleAppointment
{
    Id = 1,
    Subject = “Daily scrum meeting”,
    StartTime = new DateTime(2021, 3, 28, 11, 0, 0),
    EndTime = new DateTime(2021, 3, 28, 12, 0, 0),
    AppointmentBackground = new SolidColorBrush(Color.FromArgb(255, 0, 120, 215)),
    Foreground = new SolidColorBrush(Colors.White),
    RecurrenceRule = “FREQ=DAILY;INTERVAL=1;COUNT=10”
};
//Adding the recurring or pattern appointment to the AppointmentCollection.
appointmentCollection.Add(scheduleAppointment);

//Add exception dates 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(parent recurrence Id value), so it will be the changed 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(Color.FromArgb(255, 112, 173, 71)),
    Foreground = new SolidColorBrush(Colors.White),
    RecurrenceId = 1
};
// Adding an exception occurrence appointment to the AppointmentCollection.
appointmentCollection.Add(exceptionAppointment);
//Setting the AppointmentCollection as a ItemSource of SfScheduler.
This.Schedule.ItemsSource = appointmentCollection;

To learn more, refer to the recursive appointment exception demo.

Exception Occurrence Appointment in WinUI Scheduler

Recurrence editor

Rather than creating multiple appointments for the same time on different dates, you can use Scheduler control’s recurring appointment editor to make a single appointment recurring.

Double-click on an appointment to open the following editor.

Daily Recurrence in WinUI Scheduler
Weekly Recurrence in WinUI Scheduler
Monthly Recurrence by Day in WinUI Scheduler
Monthly Recurrence by Week in WinUI Scheduler
Yearly Recurrence by Month Day in WinUI Scheduler
Yearly Recurrence by Week in WinUI Scheduler

A single or series of recurring appointments can also be modified using the recurrence editor in WinUI Scheduler.

Edit Recurring Appointments in WinUI Scheduler
Delete Recurring Appointments in WinUI Scheduler

Conclusion

In this blog post, we had a quick overview of scheduling recurring appointments in the WinUI Scheduler. You can explore other features in the Scheduler control through our documentation, where you can find detailed explanations of each feature with code examples.

Please feel free to try out the samples available in the GitHub location and share your feedback or ask questions in the comments section. You can also contact us through our support forumssupport tickets, or feedback portal. As always, we are happy to assist you!

Related blogs

Meet the Author

Jeyasri Murugan

I'm Jeyasri Murugan, a Product Manager at Syncfusion. I have experience in developing custom controls for various .NET frameworks, including .NET MAUI, Xamarin, WPF, WinUI, and UWP.