Back to Devexpress

DataSource.AppointmentsSource Property

wpf-devexpress-dot-xpf-dot-scheduling-dot-datasource.md

latest11.8 KB
Original Source

DataSource.AppointmentsSource Property

Gets or sets a collection of objects containing appointment information. This is a dependency property.

Namespace : DevExpress.Xpf.Scheduling

Assembly : DevExpress.Xpf.Scheduling.v25.2.dll

NuGet Package : DevExpress.Wpf.Scheduling

Declaration

csharp
public object AppointmentsSource { get; set; }
vb
Public Property AppointmentsSource As Object

Property Value

TypeDescription
Object

A collection of objects which contain appointment information.

|

Remarks

The AppointmentsSource property supports the MVVM design pattern. See the MVVM Framework topic to learn more.

Important

Appointment mappings are required. Use the DataSource.AppointmentMappings property to specify mappings.

Example

View Example

csharp
using System;
using System.Collections.ObjectModel;

namespace SimpleSchedulingExample {
    public class MainViewModel {
        public virtual ObservableCollection<Doctor> Doctors { get; set; }
        public virtual ObservableCollection<MedicalAppointment> Appointments { get; set; }

        protected MainViewModel() {
            CreateDoctors();
            CreateMedicalAppointments();
        }
        private void CreateDoctors() {
            Doctors = new ObservableCollection<Doctor>();
            Doctors.Add(Doctor.Create(Id: 1, Name: "Stomatologist"));
            Doctors.Add(Doctor.Create(Id: 2, Name: "Ophthalmologist"));
            Doctors.Add(Doctor.Create(Id: 3, Name: "Surgeon"));
        }
        private void CreateMedicalAppointments() {
            Appointments = new ObservableCollection<MedicalAppointment>();
            Appointments.Add(MedicalAppointment.Create(
                startTime: DateTime.Now.Date.AddHours(10), endTime: DateTime.Now.Date.AddHours(11),
                doctorId: 1, notes: "", location: "101", categoryId:1, patientName: "Dave Muriel",
                insuranceNumber: "396-36-XXXX", firstVisit: true));
        }
    }
}
xaml
<dxsch:SchedulerControl.DataSource>
    <dxsch:DataSource AppointmentsSource="{Binding Appointments}" ResourcesSource="{Binding Doctors}">
        <dxsch:DataSource.AppointmentMappings>
            <dxsch:AppointmentMappings AllDay="AllDay"
                Description="Notes"
                End="EndTime"
                Id="Id"
                LabelId="CategoryId"
                Location="Location"
                RecurrenceInfo="RecurrenceInfo"
                Reminder="ReminderInfo"
                ResourceId="DoctorId"
                Start="StartTime"
                StatusId="StatusId"
                Subject="PatientName"
                Type="Type">
                <dxsch:CustomFieldMapping Mapping="InsuranceNumber" Name="InsuranceNumber" />
                <dxsch:CustomFieldMapping Mapping="FirstVisit" Name="FirstVisit" />
            </dxsch:AppointmentMappings>
        </dxsch:DataSource.AppointmentMappings>
        <dxsch:DataSource.ResourceMappings>
            <dxsch:ResourceMappings Caption="Name" Id="Id" />
        </dxsch:DataSource.ResourceMappings>
    </dxsch:DataSource>
</dxsch:SchedulerControl.DataSource>
csharp
public class MedicalAppointment {
    public static MedicalAppointment Create() {
        return ViewModelSource.Create(() => new MedicalAppointment());
    }
    internal static MedicalAppointment Create(DateTime startTime, DateTime endTime,
        int doctorId, string notes, string location, int categoryId, string patientName,
        string insuranceNumber, bool firstVisit) {

        MedicalAppointment apt = MedicalAppointment.Create();
        apt.StartTime = startTime;
        apt.EndTime = endTime;
        apt.DoctorId = doctorId;
        apt.Notes = notes;
        apt.Location = location;
        apt.CategoryId = categoryId; 
        apt.PatientName = patientName;
        apt.InsuranceNumber = insuranceNumber;
        apt.FirstVisit = firstVisit;
        return apt;
    }

    protected MedicalAppointment() { }

    public virtual int Id { get; set; }
    public virtual bool AllDay { get; set; }
    public virtual DateTime StartTime { get; set; }
    public virtual DateTime EndTime { get; set; }
    public virtual string PatientName { get; set; }
    public virtual string Notes { get; set; }
    public virtual string Subject { get; set; }
    public virtual int StatusId { get; set; }
    public virtual int CategoryId { get; set; }
    public virtual int Type { get; set; }
    public virtual string Location { get; set; }
    public virtual string RecurrenceInfo { get; set; }
    public virtual string ReminderInfo { get; set; }
    public virtual int? DoctorId { get; set; }
    public virtual string InsuranceNumber { get; set; }
    public virtual bool FirstVisit { get; set; }
}
vb
Public Class MedicalAppointment
    Public Shared Function Create() As MedicalAppointment
        Return ViewModelSource.Create(Function() New MedicalAppointment())
    End Function
    Friend Shared Function Create(ByVal startTime As Date, ByVal endTime As Date, ByVal doctorId As Integer, ByVal notes As String, ByVal location As String, ByVal categoryId As Integer, ByVal patientName As String, ByVal insuranceNumber As String, ByVal firstVisit As Boolean) As MedicalAppointment

        Dim apt As MedicalAppointment = MedicalAppointment.Create()
        apt.StartTime = startTime
        apt.EndTime = endTime
        apt.DoctorId = doctorId
        apt.Notes = notes
        apt.Location = location
        apt.CategoryId = categoryId
        apt.PatientName = patientName
        apt.InsuranceNumber = insuranceNumber
        apt.FirstVisit = firstVisit
        Return apt
    End Function

    Protected Sub New()
    End Sub

    Public Overridable Property Id() As Integer
    Public Overridable Property AllDay() As Boolean
    Public Overridable Property StartTime() As Date
    Public Overridable Property EndTime() As Date
    Public Overridable Property PatientName() As String
    Public Overridable Property Notes() As String
    Public Overridable Property Subject() As String
    Public Overridable Property StatusId() As Integer
    Public Overridable Property CategoryId() As Integer
    Public Overridable Property Type() As Integer
    Public Overridable Property Location() As String
    Public Overridable Property RecurrenceInfo() As String
    Public Overridable Property ReminderInfo() As String
    Public Overridable Property DoctorId() As Integer?
    Public Overridable Property InsuranceNumber() As String
    Public Overridable Property FirstVisit() As Boolean
End Class
vb
Imports System
Imports System.Collections.ObjectModel

Namespace SimpleSchedulingExample
    Public Class MainViewModel
        Public Overridable Property Doctors() As ObservableCollection(Of Doctor)
        Public Overridable Property Appointments() As ObservableCollection(Of MedicalAppointment)

        Protected Sub New()
            CreateDoctors()
            CreateMedicalAppointments()
        End Sub
        Private Sub CreateDoctors()
            Doctors = New ObservableCollection(Of Doctor)()
            Doctors.Add(Doctor.Create(Id:= 1, Name:= "Stomatologist"))
            Doctors.Add(Doctor.Create(Id:= 2, Name:= "Ophthalmologist"))
            Doctors.Add(Doctor.Create(Id:= 3, Name:= "Surgeon"))
        End Sub
        Private Sub CreateMedicalAppointments()
            Appointments = New ObservableCollection(Of MedicalAppointment)()
            Appointments.Add(MedicalAppointment.Create(startTime:= Date.Now.Date.AddHours(10), endTime:= Date.Now.Date.AddHours(11), doctorId:= 1, notes:= "", location:= "101", categoryId:=1, patientName:= "Dave Muriel", insuranceNumber:= "396-36-XXXX", firstVisit:= True))
        End Sub
    End Class
End Namespace

The following code snippets (auto-collected from DevExpress Examples) contain references to the AppointmentsSource property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-scheduler-use-scheduler-report-to-print-and-export-appointments/CS/PrintingExample/MainWindow.xaml#L44

xml
<dxsch:SchedulerControl.DataSource>
    <dxsch:DataSource AppointmentsSource="{Binding Appointments}" ResourcesSource="{Binding Doctors}">
        <dxsch:DataSource.AppointmentMappings>

wpf-scheduler-generate-time-scales-from-view-model-collection/CS/WpfSchedulerTimelineScalesTemplate/MainWindow.xaml#L43

xml
<dxsch:SchedulerControl.DataSource>
    <dxsch:DataSource AppointmentsSource="{Binding Appointments}" ResourcesSource="{Binding Calendars}">
        <dxsch:DataSource.AppointmentMappings>

wpf-scheduler-highlight-time-intervals/CS/SchedulerCellTemplate/MainWindow.xaml#L32

xml
<dxsch:SchedulerControl.DataSource>
    <dxsch:DataSource AppointmentsSource="{Binding Appointments}" ResourcesSource="{Binding Calendars}"
                      TimeRegionsSource="{Binding TimeRegions}"

wpf-scheduler-implement-custom-mapping-converter-for-color-values/CS/ColorMappingExample/MainWindow.xaml#L37

xml
<dxsch:SchedulerControl.DataSource>
    <dxsch:DataSource AppointmentLabelsSource="{Binding Categories}" AppointmentsSource="{Binding Appointments}">
        <dxsch:DataSource.AppointmentMappings>

wpf-scheduler-obtain-selected-appointment-resource-and-time-interval/CS/DXSchedulerSelection/MainWindow.xaml#L59

xml
AppointmentLabelsSource="{Binding SportGroups}"
AppointmentsSource="{Binding SportEvents}"
ResourcesSource="{Binding SportChannels}">

See Also

Appointments

DataSource Class

DataSource Members

DevExpress.Xpf.Scheduling Namespace