Collection of Custom Objects

  • 3 minutes to read

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.

The Scheduler can be bound to a collection of custom objects. This document contains a brief overview of collection types, and contains an example of code that is used to implement appointment and resource objects.

A Scheduler Storage can be bound to a System.ComponentModel.BindingList<T> class instance (a generic collection that supports data binding), or a System.Collections.ObjectModel.ObservableCollection<T> class instance (a dynamic data collection that provides notifications). When you consider the type of an item in a collection, make sure that its properties can be mapped to Scheduler Storage fields in a straightforward way (i.e., the property value type must correspond to the data type used in the mapping). This rule prohibits the use of the System.Collections.ObjectModel.ObservableCollection<DevExpress.XtraScheduler.IAppointment> collection as the data source because the AppointmentMappingInfo.RecurrenceInfo mapping requires a mapped field of the string type, not the RecurrenceInfo data type. Review the code snippet below for information on the data types required for specific mappings.

For an example of the Scheduler bound to an observable collection, review the Observable Collection document.

The following code demonstrates how to implement a custom appointment and resource objects.

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
    Partial Friend Class MainViewModel
        Public Property Doctors() As BindingList(Of Doctor)
        Public Property Appointments() As BindingList(Of HospitalAppointment)
        Public Sub New()
            Doctors = New BindingList(Of Doctor)()
            Appointments = New BindingList(Of HospitalAppointment)()
        End Sub

        Public Class Doctor
            Public Property Id() As Object
            Public Property Name() As String
        End Class

        Public Class HospitalAppointment
            Public Property PatientName() As String
            Public Property Location() As String
            Public Property StartTime() As Date
            Public Property EndTime() As Date
            Public Property InsuranceNumber() As String
            Public Property FirstVisit() As Boolean
            Public Property DoctorId() As Object
            Public Property Notes() As String
        End Class
    End Class