New to Telerik UI for WinUI? Download free 30-day trial

RecurrencePattern

RadScheduler includes support for recurring events on daily, weekly, monthly and yearly basis. Exceptions to the recurrence rules are also permitted. To support this recurrence behavior, the IAppointment interface includes the RecurrenceRule property. When an appointment is promoted into a recurring event its RecurrenceRule is set with the correct RecurrencePattern.

The RecurrenceRule class is the engine for creating and evaluating recurrence rules. It has a mandatory property Pattern of type RecurrencePattern.

RecurrencePattern Class

While the RecurrenceRule class is the engine for creating and evaluating recurrence rules, the RecurrencePattern class carries the main information about the occurrence.

The next several sections describe the main properties and methods exposed by the RecurrencePattern class.

Frequency

If you want to set the frequency of the recurrence, you need to set the RecurrencePattern's Frequency property. Its values are predefined in the RecurrenceFrequency enumeration, which exposes the following values:

  • Minutely: Use RecurrenceFrequency.Minutely whenever you want the appointment to occur every minute.

  • Hourly: Use RecurrenceFrequency.Hourly whenever you want the appointment to occur every hour.

  • Daily: Use RecurrenceFrequency.Daily whenever you want the appointment to occur every day.

  • Monthly: Use RecurrenceFrequency.Monthly whenever you want the appointment to occur every month.

  • Weekly: Use RecurrenceFrequency.Weekly whenever you want the appointment to occur every week.

  • Yearly: Use RecurrenceFrequency.Yearly whenever you want the appointment to occur every year.

The RecurrenceFrequency enumeration exposes also the following values:

  • Secondly
  • None
    However, these values are invalid recurrence frequency and should not be used.

The default value of the RecurrencePattern's Frequency property is RecurrenceFrequency.None. Which means that the Frequency property is a mandatory property and you should always set it.

Minutely and Hourly Frequency can be set only with code ( not from the EditAppointmentDialog). In order to display these options, you should customize the EditAppointmentDialogStyle and add them in the template manually.

MinutesOfHour

When you want to specify the minutes of the hour when the appointment occurs, you should set this property. It is mainly used for Minutely Frequency and should be set to an array of integers.

HoursOfDay

When you want to specify the hours of the day when the appointment occurs, you should set this property. It is mainly used for Hourly Frequency and should be set to an array of integers.

DaysOfWeekMask

When you want to set the days of the week of the recurrence, you need to set the RecurrencePattern's DaysOfWeekMask property. Its values are predefined in the RecurrenceDays enumeration, which exposes the following values:

  • EveryDay

  • Friday

  • Monday

  • Saturday

  • Sunday

  • Thursday

  • Tuesday

  • Wednesday

  • WeekDays

  • WeekendDays

  • None

The default value of the RecurrencePattern's DaysOfWeekMask property is RecurrenceDays.None. However, the DaysOfWeekMask is not a mandatory property.

RecurrenceDays.WeekDays is equivalent to RecurrenceDays.Monday | RecurrenceDays.Tuesday | RecurrenceDays.Wednesday | RecurrenceDays.Thursday | RecurrenceDays.Friday.

RecurrenceDays.WeekendDays is equivalent to RecurrenceDays.Saturday | RecurrenceDays.Sunday.

RecurrenceDays.EveryDay is equivalent to RecurrenceDays.Monday | RecurrenceDays.Tuesday | RecurrenceDays.Wednesday | RecurrenceDays.Thursday | RecurrenceDays.Friday | RecurrenceDays.Saturday | RecurrenceDays.Sunday.

Enum members are often used in logical operation to create a combination of values. Often you should set more than one value of the DaysOfWeekMask property, like in the Example section at the end of the topic.

Interval

If you want to set the number of days between each recurrence, you need to specify the RecurrencePattern's Interval property.

The default value of the RecurrencePattern's Interval property is 1.

Combining the Interval property with the DaysOfWeekMask and Frequency pattern gives you even more flexibility when creating recurring appointments. For more information take a look at the Example section at the end of the topic.

DayOfMonth

When you want to specify on which day of the month the appointment occurs, you need to set the DayOfMonth property.

DayOrdinal

When you want to specify the day ordinal (first, second, third, fourth, etc.), you need to set the DayOrdinal property. For example, you may want to create an appointment that occurs on every second Monday of every third month. Check out the solution here.

MonthOfYear

When you want to specify on which month of the year the appointment occurs, you need to set the MonthOfYear property. This property is used mainly in the Yearly appointments. Check out the Example section for more information.

MaxOccurrences

When you want to specify a limit of the occurrences for the appointment, then you need to set the MaxOccurrences property. Check out the example at the end of the topic.

RepeatUntil

When you want to specify the end date of the appointment's occurrences, then you need to set the RepatUntil property. Check out the example at the end of the topic.

Copy()

When you want to create a new instance of RecurrencePattern with the same values as a specified RecurrencePattern, then you need to use the Copy() method.

Example 1: Copy RecurrencePattern

var pattern = new RecurrencePattern() { 
    Frequency = RecurrenceFrequency.Monthly, 
    MaxOccurrences = 10 
}; 
var copyPattern = pattern.Copy(); 
In the above example, a new monthly recurrence pattern is created. It also has a limit of 10 occurrences. When you invoke the pattern.Copy() method this creates a new instance of the RecurrencePattern class with exactly the same characteristics as the source object (the Frequency property will be set to RecurrenceFrequency.Monthly and the MaxOccurrences property will be set to 10).

CopyFrom()

Use the CopyFrom() method to duplicate the pattern properties of the specified RecurrencePattern object in the RecurrencePattern object that calls this method.

Example 2: Using the CopyFrom method

var pattern = new RecurrencePattern() { 
    Frequency = RecurrenceFrequency.Monthly, 
    MaxOccurrences = 10 
}; 
var newPattern = new RecurrencePattern(); 
newPattern.CopyFrom(pattern); 

All properties in the current instance (newPattern object) will be replaced by the corresponding properties in the specified RecurrencePattern object.

Examples

For the next examples the following appointment declaration will be used.

Example 3: Appointment declaration

var startDate = new DateTime(2021, 05, 11, 10, 0, 0); 
var appointment = new Appointment() { 
    Start = startDate, 
    End = startDate.AddHours(2), 
    Subject = "Example" 
}; 

How to Create Every Day Recurring Appointment?

If you want to create an appointment that occurs every day, the only thing you should do is to set the RecurrencePattern's Frequency property to RecurrenceFrequency.Daily.

Example 4: Setting the Frequency

var pattern = new RecurrencePattern() { 
    Frequency = RecurrenceFrequency.Daily 
}; 
appointment.RecurrenceRule = new RecurrenceRule(pattern); 

Figure 1: Result from Example 4

WinUI RadScheduler RecurrencePattern

How to Create Every Week Day Recurring Appointment?

Creating an every day recurring event is extremely simple - you just need to set the Frequency property. However, if you want to create every week (working) day recurring event, setting only the Frequency property won't be enough. You will need to set the DaysOfWeekMask property, too.

Example 5: Setting the DaysOfWeekMask

var pattern = new RecurrencePattern() { 
      Frequency = RecurrenceFrequency.Weekly, 
      DaysOfWeekMask = RecurrenceDays.WeekDays 
}; 
appointment.RecurrenceRule = new RecurrenceRule(pattern); 

Figure 2: Result from Example 5

WinUI RadScheduler RecurrencePattern

Sometimes you may want to create an appointment that occurs during the weekend days, instead of every week day. The only thing you should change is to set the DaysOfWeekMask property to RecurrenceDays.WeekendDays.

If you want to create an appointment that occurs every specific week day (Monday, Tuesday, etc.), you need only to set the correct value for the DaysOfWeekMask property. For example, in order to create an appointment that occurs every Friday, set the DaysOfWeekMask property to RecurrenceDays.Friday.

How to Create an Appointment that Occurs on Every "n" Days?

When you want to create an appointment that occurs on every "n" days, you should set the Frequency, DaysOfWeekMask and the Interval properties of the RecurrencePattern object. For example, in order to create an appointment that occurs on every third day (that means the number of days between each recurrence is 3), you should:

  • Set the Frequency property to RecurrenceFrequency.Daily.

  • Set the DaysOfWeekMask property to RecurrenceDays.EveryDay.

  • Set the Interval property to 3.

Example 6: Setting the Interval

var pattern = new RecurrencePattern() { 
    Frequency = RecurrenceFrequency.Daily, 
    DaysOfWeekMask = RecurrenceDays.EveryDay, 
    Interval = 3 
}; 
appointment.RecurrenceRule = new RecurrenceRule(pattern); 

Figure 3: Result from Example 6

WinUI RadScheduler RecurrencePattern

In this example, the key moment is setting the Interval property. For example, if you want the number of days between each recurrence to be 4, 5, 6 or n days, then you just need to set the correct value to the Interval property.

How to Create an Appointment that Occurs on Every "n-th" Day of the Month and the Interval Between Each Recurrence is "m" Months?

For example, if you want to create an appointment that occurs on every fifth day of the month and the interval between each recurrence is two months, then you should perform the following steps:

  • Set the DayOfMonth property to 5.
  • Set the Frequency property to RecurrenceFrequency.Monthly.
  • Set the Interval property to 2.

Example 7: Setting the DayOfMonth, Frequency and Interval

var pattern = new RecurrencePattern() { 
    DayOfMonth = 5, 
    Frequency = RecurrenceFrequency.Monthly, 
    Interval = 2 
}; 
appointment.RecurrenceRule = new RecurrenceRule(pattern); 

How to Create an Appointment that Occurs on Every "n-th" Week Day and the Interval Between Each Recurrence is "m" Months?

For example, if you want to create an appointment that occurs on every second Monday of the month and the interval between each recurrence is two months, then you should perform the following steps:

  • Set the DayOrdinal to 2.
  • Set the Frequency property to RecurrenceFrequency.Monthly.
  • Set the DaysOfWeekMask property to RecurrenceDays.Monday.
  • Set the Interval property to 2.

Example 8: Setting the DayOrdinal, DaysOfWeekMask, Frequency and Interval

var pattern = new RecurrencePattern() { 
    DayOrdinal = 2, 
    DaysOfWeekMask = RecurrenceDays.Monday, 
    Frequency = RecurrenceFrequency.Monthly, 
    Interval = 2 
}; 
appointment.RecurrenceRule = new RecurrenceRule(pattern); 

How to Create an Yearly Appointment?

For example, if you want to create an appointment that occurs on 13th of November each year, then you should perform the following steps:

  • Set the Frequency property to RecurrenceFrequency.Yearly.
  • Set the MonthOfYear to 11.
  • Set the DayOfMonth to 13.

Example 9: Creating an Yearly Appointment

var pattern = new RecurrencePattern() { 
    Frequency = RecurrenceFrequency.Yearly, 
    MonthOfYear = 11, 
    DayOfMonth = 13 
}; 
appointment.RecurrenceRule = new RecurrenceRule(pattern); 

Set the Maximum Occurrences of the Appointment

When you want to specify a limit of the occurrences for the appointment, then you need to set the MaxOccurrences property. For example if you want to specify a limit of 3 occurences for a daily appointment, then you should set the MaxOccurrences property to 3.

Example 10: Setting the MaxOccurrences

var pattern = new RecurrencePattern() { 
    Frequency = RecurrenceFrequency.Daily, 
    MaxOccurrences = 3 
}; 
appointment.RecurrenceRule = new RecurrenceRule(pattern); 

Set the End Date of the Appointment's Occurrences

When you want to specify the end date of the appointment's occurrences, then you need to set the RepatUntil property.

Example 11: Setting the RecursUntil property

var pattern = new RecurrencePattern() { 
    Frequency = RecurrenceFrequency.Daily, 
    RecursUntil = new DateTime( 2011, 05, 24, 10, 0, 0 ) 
}; 
appointment.RecurrenceRule = new RecurrenceRule(pattern); 
In this article
Not finding the help you need?