2X faster development
The ultimate WPF UI toolkit to boost your development speed.
How to update the ItemsSource collection using default editor?
You can update the local appointment collection by using the editor events in SfSchedule control. This article explains about how to update the local appointment collection by using default editor. Updating the local appointment collection using default editor
XAML <syncfusion:SfSchedule x:Name="sched" ScheduleType="Month" > </syncfusion:SfSchedule>
C# public class clsAppointment : INotifyPropertyChanged { private bool m_AllDay; public bool AllDay { get { return m_AllDay; } set { m_AllDay = value; OnPropertyChanged("AllDay"); } } private System.DateTime m_EndDateTime; public System.DateTime EndDateTime { get { return m_EndDateTime; } set { m_EndDateTime = value; OnPropertyChanged("EndDateTime"); } } private string m_Location; public string Location { get { return m_Location; } set { m_Location = value; OnPropertyChanged("Location"); } } private string m_Notes; public string Notes { get { return m_Notes; } set { m_Notes = value; OnPropertyChanged("Notes"); } } private System.DateTime m_StartDateTime; public System.DateTime StartDateTime { get { return m_StartDateTime; } set { m_StartDateTime = value; OnPropertyChanged("StartDateTime"); } } private string m_Subject; public string Subject { get { return m_Subject; } set { m_Subject = value; OnPropertyChanged("Subject"); } } public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChanged(string propertyName) { var eventHandler = this.PropertyChanged; if (eventHandler != null) eventHandler(this, new PropertyChangedEventArgs(propertyName)); } }
C# private ObservableCollection<clsAppointment> m_Source = new ObservableCollection<clsAppointment>(); public ObservableCollection<clsAppointment> Source { get { return m_Source; } set { m_Source = value; } }
C# private void sched_AppointmentEditorClosed(object sender, AppointmentEditorClosedEventArgs e) { if (e.Action == EditorClosedAction.Save) { if (e.IsNew) { AddNewClsAppointment(e.EditedAppointment); } } if (e.Action == EditorClosedAction.Delete) { RemoveClsAppointment(e.OriginalAppointment); } e.Handled = true; } private void AddNewClsAppointment(object appointment) { if (appointment is clsAppointment) { var scheduleAppointment = appointment as clsAppointment; Source.Remove(scheduleAppointment); } } private void RemoveClsAppointment(object appointment) { if (appointment is clsAppointment) { var scheduleAppointment = appointment as clsAppointment; Source.Remove(scheduleAppointment); } } private static void UpdateClsAppointment(ScheduleAppointment scheduleAppointment, SfSchedule_AppointmentClass.clsAppointment clsAppointment) { clsAppointment.Subject=scheduleAppointment.Subject; clsAppointment.AllDay = scheduleAppointment.AllDay; clsAppointment.Location = scheduleAppointment.Location; clsAppointment.Notes = scheduleAppointment.Notes; clsAppointment.StartDateTime = scheduleAppointment.StartTime; clsAppointment.EndDateTime = scheduleAppointment.EndTime; }
In the above code example, by using the e.EditedAppointment and e.OriginalAppointment value, you can update the custom appointment collection.
XAML <syncfusion:SfSchedule.AppointmentMapping> <syncfusion:ScheduleAppointmentMapping SubjectMapping="Subject" NotesMapping="Notes" LocationMapping="Location" StartTimeMapping="StartDateTime" EndTimeMapping="EndDateTime" AllDayMapping="AllDay" /> </syncfusion:SfSchedule.AppointmentMapping> After completing the above steps, run the project and the local appointment collection gets updated when you Add and Delete an appointment using Appointment Editor. Sample
|
2X faster development
The ultimate WPF UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.
Tried with above sample
1) Unable to edit and convert normal appointment to allday event 2) can't create new allday appointment
Hi MADHAVAN,
Currently we have updated the code related to add appointments. Before we have maintained the appointment type as ScheduleAppointment . But now we have updated type as object to avoid unwanted conversion while adding new appointments. So we can get custom appointment directly. Please find the code snippet and sample for the same. And we will update the same in our KB and it will be published in our upcoming release.
Code Snippet:
Modified Sample: http://www.syncfusion.com/downloads/support/directtrac/general/ze/SFSCHE~11125987106
Regards, Magesh S