Articles in this section
Category / Section

How to add additional entities to the SheduleAppointment class?

1 min read

 

You can add additional entities to the ScheduleAppointment class in the schedule control. This article explains how to add additional entities to the ScheduleAppointment class in the schedule control.

Adding additional entities in the ScheduleAppointment class:

  1. Create a WPF application and add Schedule control to it.

XAML

<syncfusion:SfSchedule  ScheduleType="Month" x:Name="schedule"  >
 </syncfusion:SfSchedule>
  1. Create the custom appointment class with the needed property. We have used the below code snippet to add custom appointment class with String_ID property.

C#

     public class CustomAppointment : ScheduleAppointment,INotifyPropertyChanged
    {
 
        private string _String_ID;
        public string String_ID
        {
            get { return _String_ID; }
            set { _String_ID = value; OnPropertyChanged("String_ID"); }
        }
 
 
        public event PropertyChangedEventHandler PropertyChanged;
 
        private void OnPropertyChanged(string propertyName)
        {
            var eventHandler = this.PropertyChanged;
            if (eventHandler != null)
                eventHandler(this, new PropertyChangedEventArgs(propertyName));
        }
    }        
  1. In the above code we have inherited the custom appointment class from the ScheduleAppointment class. So that, we can use the existing ScheduleAppointment’s properties as well as the additional added property in the CustomAppointment class.
  2. Create ScheduleAppointmentCollection property and add appointments by using CustomAppointment class. We have used below code snippet to add appointment in ScheduleAppointmentColletion.

C#

private ScheduleAppointmentCollection m_Source = new ScheduleAppointmentCollection();
        public ScheduleAppointmentCollection Source
        {
            get { return m_Source; }
            set { m_Source = value; }
        }
        public MainWindow()
        {
            InitializeComponent();
            Source = new ScheduleAppointmentCollection
            { 
                new CustomAppointment{String_ID="1",Subject="Meeting",StartTime=DateTime.Now.AddHours(1),EndTime=DateTime.Now.AddHours(2)},
                new CustomAppointment{String_ID="2",Subject="CheckUp",StartTime=DateTime.Now.AddDays(28).AddHours(1),EndTime=DateTime.Now.AddDays(28).AddHours(2)},
                new CustomAppointment{String_ID="3",Subject="Conference",StartTime=DateTime.Now.AddDays(1),EndTime=DateTime.Now.AddDays(1).AddHours(2)}
 
            };
            this.DataContext = this;
         
         
        }
  1. Now bind the itemsource with ScheduleAppointmentColletion property and map the CustomAppointment class properties using AppointmentMapping property in the schedule control. We have used below code snippet for mapping the CustomAppointment class.

 

XAML

<syncfusion:SfSchedule  x:Name="schedule" ScheduleType="Month" ItemsSource="{Binding Source,Mode=TwoWay}" >  
 
 <syncfusion:SfSchedule.AppointmentMapping>
                <syncfusion:ScheduleAppointmentMapping SubjectMapping="Subject" StartTimeMapping="StartTime" EndTimeMapping="EndTime"></syncfusion:ScheduleAppointmentMapping>
            </syncfusion:SfSchedule.AppointmentMapping>
 
  </syncfusion:SfSchedule>

 

The following screenshot displays the appointments with additional entities added to the ScheduleAppointment.

Figure 1: Schedule appointment with additional entity

Sample Link:

Schedule_CustomAppointment_WPF

 

 

 

 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments
Please sign in to leave a comment
Access denied
Access denied