RadCalendar can display appointments in its month view by using its
AppointmentsSource property.
The appointments source is defined as a new class that inherits from the base abstract class Telerik.Windows.Controls.AppointmentSource. By using this base
class developers are able to display appointments from any source – phone device, their own web service or a third party appointments data. Here is a simple implementation of
sample appointments source:
CopyC#
public class SampleAppointmentSource : AppointmentSource
{
public SampleAppointmentSource()
{
}
public override void FetchData(DateTime startDate, DateTime endDate)
{
this.AllAppointments.Clear();
this.AllAppointments.Add(new SampleAppointment()
{
StartDate = DateTime.Now,
EndDate = DateTime.Now.AddHours(1),
Subject = "Today Appointment 1",
Details = "Some Long Details are coming here",
Location = "My Home Town"
});
this.AllAppointments.Add(new SampleAppointment()
{
StartDate = DateTime.Now.AddMinutes(30),
EndDate = DateTime.Now.AddHours(1),
Subject = "Today Appointment 2",
Details = "Some Long Details are coming here",
Location = "Paris"
});
this.OnDataLoaded();
}
}
Here is and how the SampleAppointment looks like:
CopyC#
public class SampleAppointment : IAppointment
{
public string Details
{
get;
set;
}
public DateTime EndDate
{
get;
set;
}
public string Location
{
get;
set;
}
public DateTime StartDate
{
get;
set;
}
public string Subject
{
get;
set;
}
public override string ToString()
{
return this.Subject;
}
}
Please note that the appointment should implement the
Telerik.Windows.Controls.IAppointment interface.
Once we have the appointments source declared we just need to set it to RadCalendar:
CopyC#
RadCalendar1.AppointmentSource = new SampleAppointmentSource();
As you can see it is pretty straightforward process in implementing an arbitrary appointment source. The FetchData method needs to be overridden and the
OnDataLoaded method should be called once the data is loaded, so that the consumers of this data source (like RadCalendar) can be notified when
new data is available.