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

Import/Export to ICalendar

The RadScheduleView allows for importing and exporting data to the ICalendar format. This is supported through the AppointmentCalendarImporter and AppointmentCalendarExporter classes.

Check out the Ical RadScheduleView example from our demos, which demonstrates this feature.

AppointmentCalendarImporter

You can import data in the ICalendar format by using the AppointmentCalendarImporter. It exposes an Import method, which expects a TextReader object with the content that should be imported and returns a collection of IAppointment objects, which can be set to the AppointmentsSource of the RadScheduleView.

Example 1: Using the AppointmentCalendarImporter

using (StreamReader reader = File.OpenText("myfile.ics")) 
{ 
    var importer = new AppointmentCalendarImporter(); 
    var appointments = importer.Import(reader); 
 
    // "this.scheduleView" refers to the RadScheduleView instance that you are targeting 
    this.scheduleView.AppointmentsSource = appointments; 
}    
Using reader As StreamReader = File.OpenText("myfile.ics") 
    Dim importer = New AppointmentCalendarImporter() 
    Dim appointments = importer.Import(reader) 
 
    ' "this.scheduleView" refers to the RadScheduleView instance that you are targeting 
    Me.scheduleView.AppointmentsSource = appointments 
End Using 

AppointmentCalendarExporter

You can export the appointments from RadScheduleView to a file in the ICalendar format with the help of the AppointmentCalendarExporter. You can use its Export method, which receives a collection of appointments and a TextWriter object.

Example 2: Using the AppointmentCalendarExporter

using (StreamWriter writer = File.CreateText("myfile.ics")) 
{ 
    var exporter = new AppointmentCalendarExporter(); 
 
    // "this.scheduleView" refers to the RadScheduleView instance that you are targeting 
    var apps = this.scheduleView.AppointmentsSource.OfType<Appointment>(); 
    exporter.Export(apps, writer); 
} 
Using writer As StreamWriter = File.CreateText("myfile.ics") 
    Dim exporter = New AppointmentCalendarExporter() 
 
    ' "this.scheduleView" refers to the RadScheduleView instance that you are targeting 
    Dim apps = Me.scheduleView.AppointmentsSource.OfType(Of Appointment)() 
    exporter.Export(apps, writer) 
End Using 

The AppointmentCalendarExporter and AppointmentCalendarImporter classes expose some useful virtual methods, which can be overriden in a derived class in cases where the import or export behavior needs to be customized.

See Also

In this article