# RecurrencePattern

Use `RecurrencePattern` to configure daily, weekly, monthly, and yearly appointments in the `RadScheduleView` control. The `IAppointment` interface exposes a `RecurrenceRule` property that associates an appointment with a recurrence pattern. Recurrence rules also support exceptions.

The [`RecurrenceRule` class](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencerule) creates and evaluates recurrence rules. Its required `Pattern` property has type `RecurrencePattern`.

This article covers the following properties, methods, and examples:

* Main properties of the `RecurrencePattern` class:

  * [`Frequency`](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#frequency)

  * [`MinutesOfHour`](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#minutesofhour)

  * [`HoursOfDay`](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#hoursofday)

  * [`DaysOfWeekMask`](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#daysofweekmask)

  * [`Interval`](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#interval)

  * [`DaysOfMonth`](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#daysofmonth)

  * [`DayOrdinal`](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#dayordinal)

  * [`MonthOfYear`](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#monthofyear)

  * [`MaxOccurrences`](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#maxoccurrences)

  * [`FirstDayOfWeek`](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#firstdayofweek)

  * [`RecursUntil`](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#recursuntil)

* Main methods of the `RecurrencePattern` class:

  * [`Copy()`](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#copy)

  * [`CopyFrom()`](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#recurrencepattern-copyfrom)

* [Examples of recurring appointments](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#examples):

  * [Create a daily appointment](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#how-to-create-every-day-recurring-appointment)

  * [Create a weekday appointment](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#how-to-create-every-week-day-recurring-appointment)

  * [Create an appointment every n days](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#how-to-create-an-appointment-that-occurs-on-every-n-days)

  * [Create an appointment on the n-th day every m months](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#how-to-create-an-appointment-that-occurs-on-every-n-th-day-of-the-month-and-the-interval-between-each-recurrence-is-m-months)

  * [Create an appointment on the n-th weekday every m months](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#how-to-create-an-appointment-that-occurs-on-every-n-th-week-day-and-the-interval-between-each-recurrence-is-m-months)

  * [Create a yearly appointment](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#how-to-create-an-yearly-appointment)

  * [Set the maximum number of occurrences](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#set-the-maximum-occurrences-of-the-appointment)

  * [Set the end date of occurrences](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#set-the-end-date-of-the-appointment-occurrences)

## RecurrencePattern Class

The `RecurrencePattern` class defines the recurrence settings that a `RecurrenceRule` uses to generate occurrences.

The `RecurrencePattern` class is in the `Telerik.Windows.Controls.ScheduleView` namespace of the `Telerik.Windows.Controls.ScheduleView.dll` assembly.

## Frequency

Set the `Frequency` property to a value from the `RecurrenceFrequency` enumeration:

* `Minutely`—Use `RecurrenceFrequency.Minutely` for appointments that occur every minute (available starting with Q3 2012 SP1).

* `Hourly`—Use `RecurrenceFrequency.Hourly` for appointments that occur every hour (available starting with Q3 2012 SP1).

* `Daily`—Use `RecurrenceFrequency.Daily` for appointments that occur every day.

* `Monthly`—Use `RecurrenceFrequency.Monthly` for appointments that occur every month.

* `Weekly`—Use `RecurrenceFrequency.Weekly` for appointments that occur every week.

* `Yearly`—Use `RecurrenceFrequency.Yearly` for appointments that occur every year.

> important Do not use `RecurrenceFrequency.Secondly` or `RecurrenceFrequency.None` as a recurrence frequency. Although the enumeration includes these values, they are invalid for recurring appointments.

The default value of `Frequency` is `RecurrenceFrequency.None`. Always set `Frequency` to a valid value when you configure a recurring appointment.

> note Set `Minutely` and `Hourly` frequencies in code. To display these options in the **EditRecurrenceDialog**, [customize the `EditRecurrenceDialogStyle`](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/custom-dialogs) and add them to the template manually.

## MinutesOfHour

Set `MinutesOfHour` to an array of integers to specify the minutes of the hour when the appointment occurs. This property is mainly used with the `Minutely` frequency.

## HoursOfDay

Set `HoursOfDay` to an array of integers to specify the hours of the day when the appointment occurs. This property is mainly used with the `Hourly` frequency.

## DaysOfWeekMask

Set `DaysOfWeekMask` to specify the days of the week when the appointment occurs. The `RecurrenceDays` enumeration includes these values:

* `EveryDay`

* `Friday`

* `Monday`

* `Saturday`

* `Sunday`

* `Thursday`

* `Tuesday`

* `Wednesday`

* `WeekDays`

* `WeekendDays`

* `None`

The default value of `DaysOfWeekMask` is `RecurrenceDays.None`. This property is optional.

`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`.

> tip Combine `RecurrenceDays` members with the bitwise OR operator (`|`) to select multiple days for `DaysOfWeekMask`. See the [recurring appointment examples](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#examples).

## Interval

Set `Interval` to specify the number of frequency units between occurrences. With `Frequency` set to `RecurrenceFrequency.Daily`, the interval is in days. With `RecurrenceFrequency.Monthly`, it is in months.

The default value of `Interval` is `1`.

> tip Combine `Interval`, `DaysOfWeekMask`, and `Frequency` to configure the [recurring appointment examples](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#examples).

## DaysOfMonth

Set `DaysOfMonth` to specify the day of the month when the appointment occurs.

## DayOrdinal

Set `DayOrdinal` to specify the ordinal position of a day, such as first, second, third, or fourth. For example, configure an appointment for the second Monday of every third month.

## MonthOfYear

Set `MonthOfYear` to specify the month when the appointment occurs. This property is mainly used for yearly appointments. See the [yearly appointment example](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#how-to-create-an-yearly-appointment).

## MaxOccurrences

Set `MaxOccurrences` to limit the number of appointment occurrences. See the [example of limiting occurrences](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#set-the-maximum-occurrences-of-the-appointment).

## FirstDayOfWeek

`FirstDayOfWeek` gets or sets the day on which the week starts. This property is only meaningful when `Frequency` is `RecurrenceFrequency.Weekly` and `Interval` is greater than `1`.

## RecursUntil

Set `RecursUntil` to specify the end date of appointment occurrences. See the [example of setting an end date](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#set-the-end-date-of-the-appointment-occurrences).

## Copy()

Use `Copy()` to create a new `RecurrencePattern` instance with the same values as an existing pattern.

```C#
var pattern = new RecurrencePattern()
{
    Frequency = RecurrenceFrequency.Monthly,
    MaxOccurrences = 10
};
var copyPattern = pattern.Copy();
```

```VB.NET
	Dim pattern = New RecurrencePattern() With {
	    .Frequency = RecurrenceFrequency.Monthly,
	    .MaxOccurrences = 10
	}
	Dim 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).

<a id="recurrencepattern-copyfrom"></a>

## CopyFrom()

Use `CopyFrom()` to copy properties from a specified `RecurrencePattern` to the instance that calls the method.

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

```VB.NET
	Dim pattern = New RecurrencePattern() With {
	    .Frequency = RecurrenceFrequency.Monthly,
	    .MaxOccurrences = 10
	}
	Dim newPattern As 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

Before using these examples, [set up a `RadScheduleView` project](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/getting-started/getting-started). The examples use the following appointment declaration.

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

```VB.NET
	Dim startDate = New DateTime(2011, 5, 11, 10, 0, 0)
	Dim appointment = New Appointment() With {
	    .Start = startDate,
	    .End = startDate.AddHours(2),
	    .Subject = "Example"
	}
```

The sample appointment starts on May 11, 2011 at 10:00 AM and lasts two hours.

## How to Create Every Day Recurring Appointment?

To create a daily appointment, set `Frequency` to `RecurrenceFrequency.Daily`.

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

```VB.NET
	Dim pattern = New RecurrencePattern() With {
	    Frequency = RecurrenceFrequency.Daily
	}
	appointment.RecurrenceRule = New RecurrenceRule(pattern)
```

The following image shows the daily recurrence.

![RadScheduleView showing the Example appointment on each day of the week](https://www.telerik.com/products/wpf/documentation/assets/f4d66fa0b6e07d5a8ba19b057082190e/radscheduleview_recurrencypattern_1.png)

## How to Create Every Week Day Recurring Appointment?

To create a weekday appointment, set both [`Frequency`](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#frequency) and [`DaysOfWeekMask`](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern#daysofweekmask).

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

```VB.NET
	Dim pattern = New RecurrencePattern() With {
	     .Frequency = RecurrenceFrequency.Weekly,
	     .DaysOfWeekMask = RecurrenceDays.WeekDays
	}
	appointment.RecurrenceRule = New RecurrenceRule(pattern)
```

The following image shows the weekday recurrence.

![RadScheduleView showing the Example appointment on working days](https://www.telerik.com/products/wpf/documentation/assets/e818b527ec65f030e67ef2a8540b1f49/radscheduleview_recurrencypattern_2.png)

> tip For weekend appointments, set `DaysOfWeekMask` to `RecurrenceDays.WeekendDays`.

For a specific day of the week, set the corresponding `DaysOfWeekMask` value. For example, use `RecurrenceDays.Friday` for appointments that occur every Friday.

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

To create an appointment every third day, set these `RecurrencePattern` properties:

* Set `Frequency` to `RecurrenceFrequency.Daily`.

* Set `DaysOfWeekMask` to `RecurrenceDays.EveryDay`.

* Set `Interval` to `3`.

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

```VB.NET
	Dim pattern = New RecurrencePattern() With {
	     .Frequency = RecurrenceFrequency.Daily,
	     .DaysOfWeekMask = RecurrenceDays.EveryDay,
	     .Interval = 3
	}
	appointment.RecurrenceRule = New RecurrenceRule(pattern)
```

The following image shows an appointment that occurs every third day.

![RadScheduleView showing the Example appointment at three-day intervals](https://www.telerik.com/products/wpf/documentation/assets/b1fe6d2b412439e8396fe7fd19181b0c/radscheduleview_recurrencypattern_3.png)

> tip For a daily frequency, set `Interval` to the required number of days between occurrences, such as `4`, `5`, or `6`.

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

To create an appointment on the fifth day of every second month, set these properties:

* Set `DaysOfMonth` to `5`.

* Set `Frequency` to `RecurrenceFrequency.Monthly`.

* Set `Interval` to `2`.

```C#
var pattern = new RecurrencePattern()
{
    DaysOfMonth = new int[] { 5 },
    Frequency = RecurrenceFrequency.Monthly,
    Interval = 2
};
appointment.RecurrenceRule = new RecurrenceRule(pattern);
```

```VB.NET
	Dim pattern = New RecurrencePattern() With {
	     .DaysOfMonth = New int[] { 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?

To create an appointment on the second Monday of every second month, set these properties:

* Set `DayOrdinal` to `2`.

* Set `Frequency` to `RecurrenceFrequency.Monthly`.

* Set `DaysOfWeekMask` to `RecurrenceDays.Monday`.

* Set `Interval` to `2`.

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

```VB.NET
	Dim pattern = New RecurrencePattern() With {
	     .DayOrdinal = 2,
	     .DaysOfWeekMask = RecurrenceDays.Monday,
	     .Frequency = RecurrenceFrequency.Monthly,  
	     .Interval = 2
	}
	appointment.RecurrenceRule = New RecurrenceRule(pattern)
```

## How to Create an Yearly Appointment?

To create an appointment on November 13 each year, set these properties:

* Set `Frequency` to `RecurrenceFrequency.Yearly`.

* Set `MonthOfYear` to `11`.

* Set `DaysOfMonth` to `13`.

```C#
var pattern = new RecurrencePattern()
{
    Frequency = RecurrenceFrequency.Yearly,
    MonthOfYear = 11,
    DaysOfMonth = new int[] { 13 }
};
appointment.RecurrenceRule = new RecurrenceRule(pattern);
```

```VB.NET
	Dim pattern = New RecurrencePattern() With {
	    .Frequency = RecurrenceFrequency.Yearly,
	    .MonthOfYear = 11,
	    .DaysOfMonth = New int[] { 13 }
	}
	appointment.RecurrenceRule = New RecurrenceRule(pattern)
```

## Set the Maximum Occurrences of the Appointment

For a daily appointment with a limit of three occurrences, set `MaxOccurrences` to `3`.

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

```VB.NET
	Dim pattern = New RecurrencePattern() With {
	    .Frequency = RecurrenceFrequency.Daily,
	    .MaxOccurrences = 3
	}
	appointment.RecurrenceRule = New RecurrenceRule(pattern)
```

## Set the End Date of the Appointment Occurrences

Set `RecursUntil` to the end date of the appointment occurrences.

```C#
var pattern = new RecurrencePattern()
{
    Frequency = RecurrenceFrequency.Daily,
    RecursUntil = new DateTime(2011, 05, 24, 10, 0, 0)
};
appointment.RecurrenceRule = new RecurrenceRule(pattern);
```

```VB.NET
	Dim pattern = New RecurrencePattern() With {
	     .Frequency = RecurrenceFrequency.Daily,
	     .RecursUntil = New DateTime(2011, 5, 24, 10, 0, 0)
	}
	appointment.RecurrenceRule = New RecurrenceRule(pattern)
```

The following image shows daily occurrences from May 11, 2011 until May 24, 2011.

![RadScheduleView month view with Example appointments starting May 11 and ending May 24, 2011](https://www.telerik.com/products/wpf/documentation/assets/dfc343f87b79921db254e8d81952b79f/radscheduleview_recurrencypattern_4.png)

## See Also

* [Creating recurrence rules and handling exceptions](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-recurrencerule)
* [Overview of recurring appointments](https://www.telerik.com/products/wpf/documentation/controls/radscheduleview/features/recurrence/recurrences-overview)
