MindFusion.Scheduling for Silverlight Programmer's Guide
Tutorial 2: Creating Recurrent Items

This tutorial shows how to programmatically create recurring items using MindFusion.Scheduling for Silverlight.

1. Create and initialize a new Silverlight application project

Follow steps 1 through 3 from the previous tutorial.

Set CurrentView to WeekRange, Date to Jan 1, 2010 and EndDate to Mar 1, 2010, respectively.

2. Create an appointment

Create a new appointment in the page's constructor. To create the appointment, add the following lines of code after the call to InitializeComponent.

 Note

Be sure to include both MindFusion.Scheduling and MindFusion.Scheduling.Silverlight namespaces via the using (Imports in Visual Basic) keyword in the beginning of the file.

C#  Copy Code

Appointment app = new Appointment();
app.HeaderText = "Meet George";
app.DescriptionText = "This is a sample appointment";
app.StartTime = new DateTime(2010, 1, 10, 14, 0, 0);
app.EndTime = new DateTime(2010, 1, 10, 16, 30, 0);

calendar.Schedule.Items.Add(app);

Visual Basic  Copy Code

Dim app As New Appointment()
app.HeaderText = "Meet George"
app.DescriptionText = "This is a sample appointment"
app.StartTime = new DateTime(2010, 1, 10, 14, 0, 0)
app.EndTime = new DateTime(2010, 1, 10, 16, 30, 0)

calendar.Schedule.Items.Add(app)

The code above creates a new appointment on 10th of January, 2010, starting at 2:00 PM and ending at 4:30 PM.

3. Create the recurrence

Now that the appointment is added to the schedule, create a Recurrence object that defines how the appointment recurs. The following code creates and initializes a new Recurrence object and associates it with the item. Append these lines to the main page's constructor.

C#  Copy Code

Recurrence rec = new Recurrence();
rec.Pattern = RecurrencePattern.Weekly;
rec.DaysOfWeek = DaysOfWeek.Monday | DaysOfWeek.Wednesday;
rec.Weeks = 2;
rec.StartDate = new DateTime(2010, 1, 10);
rec.RecurrenceEnd = RecurrenceEnd.Never;

app.Recurrence = rec;

Visual Basic  Copy Code

Dim rec As New Recurrence()
rec.Pattern = RecurrencePattern.Weekly
rec.DaysOfWeek = DaysOfWeek.Monday + DaysOfWeek.Wednesday
rec.Weeks = 2
rec.StartDate = new DateTime(2010, 1, 10)
rec.RecurrenceEnd = RecurrenceEnd.Never

app.Recurrence = rec

This fragment creates a new recurrence object that continues infinitely and repeats the appointment on Monday and Wednesday every two weeks.

4. Build and run

Compile and run the application. The image below depicts what the application output would look like.