Skip to main content
A newer version of this page is available. .

XPO (eXpress Persistent Objects)

  • 3 minutes to read

Note

You are viewing documentation for the legacy WPF Scheduler control. If you’re starting a new project, we strongly recommend that you use a new control declared in the DevExpress.Xpf.Scheduling namespace. If you decide to upgrade an existing project in order to switch to the updated scheduler control, see the Migration Guidelines document.

A Scheduler Storage can be bound to an XPCollection object provided by the eXpress Persistent Objects suite. For example, the following code demonstrates how to implement custom appointment and resource classes, which are the XPObject class descendants.

using DevExpress.Xpo;
using DevExpress.Xpo.Metadata;
// ...

public class CustomAppointment : XPObject {
    public CustomAppointment(Session session) : base(session) { }

    public int AppointmentType;
    public DateTime StartDate;
    public DateTime EndDate;
    public bool AllDay;
    public string Subject;
    public string Location;
    [Size(SizeAttribute.Unlimited)]
    public string Description;
    public int Status;
    public long Label;
    [Size(SizeAttribute.Unlimited)]
    public string RecurrenceInfo;
    [Size(SizeAttribute.Unlimited)]
    public string ReminderInfo;
    [Size(SizeAttribute.Unlimited)]
    public string CustomField1;

    public CustomResource Resource;
}

public class CustomResource : XPObject {
    public CustomResource(Session session) : base(session) { }

    [Size(SizeAttribute.Unlimited)]
    public string ResourceName;
    [ValueConverter(typeof(ColorValueConverter))]
    public Color Color;
    public Image Image;
    [Size(SizeAttribute.Unlimited)]
    public string CustomField1;
}

public class ColorValueConverter : ValueConverter {
    public override Type StorageType { get { return typeof(Int32); } }
    public override object ConvertToStorageType(object value) {
        if (!(value is Color)) return null;
        return ((Color)value).ToArgb();
    }
    public override object ConvertFromStorageType(object value) {
        if (!(value is Int32)) return null;
        return Color.FromArgb((Int32)value);
    }
}