Skip to main content

IAppointmentFactory Interface

Provides methods for creating appointments.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v23.2.Core.dll

NuGet Package: DevExpress.Scheduler.Core


public interface IAppointmentFactory

The following members return IAppointmentFactory objects:



Creating custom appointments is not safe and may lead to the control malfunction. It is strongly recommended that you use custom fields and mappings instead.

The IAppointmentFactory interface declares the IAppointmentFactory.CreateAppointment method, which defines a way of creating appointments. To specify a custom way of creating appointments using the SchedulerStorage you should implement this method and then assign the new appointment factory to the Scheduler Storage via the SchedulerStorageBase.SetAppointmentFactory method.

Then the Scheduler Storage will use this factory when creating an appointment via its SchedulerStorageBase.CreateAppointment method.

The following code illustrates the use of the IAppointmentFactory interface to implement a wrapper class which is intended to expose custom fields as common object properties. Using the AppointmentStorageBase.SetAppointmentFactory method, Scheduler’s Appointment objects are replaced with the Task class instances. A TaskCollection class holds Task objects, and can be used as a data source capable of providing data contained within appointment custom fields.

public class TaskFactory : IAppointmentFactory
    public Appointment CreateAppointment(AppointmentType type)
        Task task = new Task(type);
        return task;
public class Task : DevExpress.XtraScheduler.Internal.Implementations.AppointmentInstance {

    public Task()  { }
    public Task (AppointmentType type) : base(type){}

    // Convert custom fields into the Task properties
    public string CustomText {
        get { return (string)base.CustomFields["CustomTextField"]; }
        set { base.CustomFields["CustomTextField"] = value; }
    public Color CustomColor {
        get { return (Color)base.CustomFields["CustomColorField"]; }
        set { base.CustomFields["CustomColorField"] = value; }
    public int CustomColorARGB { get { return ((Color)base.CustomFields["CustomColorField"]).ToArgb(); } }
public class TaskCollection : List<Task> {

    public void AddAppointment(Appointment appointment) {
        Task task = (Task)appointment;

    public virtual void AddAppointmentRange(AppointmentBaseCollection collection) {
        foreach(Appointment item in collection)
See Also