Skip to main content

How to: Create Recurrence in Code

  • 2 minutes to read

This section demonstrates how to create recurring appointments in code which have different periodicity and number of occurrences.

Perform the following steps:

  1. Create a new AppointmentItem of the AppointmentType.Pattern type.
  2. Specify its recurrence information using the AppointmentItem.RecurrenceInfo property.
  3. Add an appointment to the SchedulerControl.AppointmentItems collection.

The following examples show how to create appointments with different recurrence types:

You can create recurring time regions in the same manner.

When the Scheduler is in bound mode, you can define a recurrence rule at the view model level. To do this, update the target data item’s property mapped to AppointmentItem.RecurrenceInfo with a corresponding recurrence rule info information. Use the RecurrenceInfo’s ToXML method to save this rule as a string:

[Command]
public void AddAppt(bool recurrent = false) {
    var appt = CreateAppt($"New Appt #{Appointments.Count}", Interval.Start, Interval.End, "[add description]");

    if(recurrent) {
        appt.Type = (int)AppointmentType.Pattern;
        appt.RecurrenceInfo = RecurrenceBuilder.Daily(Interval.Start, 10).Build().ToXml();
    } else {
        appt.Type = (int)AppointmentType.Normal;
    }
    ...
}

Refer to the How to: Create Regular and Recurrent Appointments at the View Model Level example for more information.