Easily Schedule Recurring Events in WinUI Scheduler | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (174).NET Core  (29).NET MAUI  (207)Angular  (109)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (41)Black Friday Deal  (1)Blazor  (215)BoldSign  (14)DocIO  (24)Essential JS 2  (107)Essential Studio  (200)File Formats  (66)Flutter  (133)JavaScript  (221)Microsoft  (119)PDF  (81)Python  (1)React  (100)Streamlit  (1)Succinctly series  (131)Syncfusion  (915)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (51)Windows Forms  (61)WinUI  (68)WPF  (159)Xamarin  (161)XlsIO  (36)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (147)Chart  (131)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (63)Development  (628)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (40)Extensions  (22)File Manager  (7)Gantt  (18)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (507)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (43)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (52)Security  (3)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (10)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (387)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (592)What's new  (332)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Easily Schedule Recurring Events in WinUI Scheduler

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
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
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
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
Daily Recurrence in WinUI Scheduler
Weekly Recurrence in WinUI Scheduler
Weekly Recurrence in WinUI Scheduler
Monthly Recurrence by Day in WinUI Scheduler
Monthly Recurrence by Day in WinUI Scheduler
Monthly Recurrence by Week in WinUI Scheduler
Monthly Recurrence by Week in WinUI Scheduler
Yearly Recurrence by Month Day in WinUI Scheduler
Yearly Recurrence by Month Day in WinUI Scheduler
Yearly Recurrence by Week 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 Appointment in WinUI Scheduler
Edit Recurring Appointments in WinUI Scheduler
Delete Recurring Appointment 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

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed