schedule.OnAppointmentLoadedEvent not working

I am trying to do the example where it adds a button to the month cell when an appointment is loaded but it never fires off the event.


 // add event handler for appointments
            schedule.OnAppointmentLoadedEvent += Schedule_OnAppointmentLoadedEvent;




           

        void Schedule_OnAppointmentLoadedEvent(object sender, AppointmentLoadedEventArgs args)
        {
            Button button = new Button();
            button.BackgroundColor = Color.Green;
            button.Text = "appt";
            args.view = button;

        }
 



scheduleAppointmentCollection.Add(new ScheduleAppointment()
                {
                    StartTime = myduedate,
                    EndTime = myduedate,
                    Subject = "Litter Due",
                    Location = "Duedate",
                });

Any reason adding the new appointment wouldnt call my event handler?

I am using the latest VS, Xamarin Forms and SfSchedule.

Thanks in advance!


3 Replies

SG Swathi Gopal Syncfusion Team December 4, 2017 11:37 AM UTC

Hi Russell, 
  
Thank you for contacting Syncfusion Support. 
  
In SfSchedule Monthview, appointments are not viewed in the month cell instead appointment indicators alone are drawn in Xamarin Forms.Thus AppointmentLoaded event will not be fired in month view.Your requirement of adding custom view(button) to month cell when appointment is loaded can be achieved using MonthCellLoaded event.We have prepared a simple sample for the same, in which button is loaded for appointments added in the month cell.Kindly find the sample from the below link 
  
  
You can also refer our online user guide documentation for customizing month cell from below link, 
  
  
If the provided solution doesn’t meet your requirement, please revert us with more information so that we could analyze on it and provide you with the better solution. 
  
Regards, 
Swathi G 



AD Andy Dent January 9, 2018 06:12 AM UTC

Your sample MonthCell_Customization-2049365571.zip has a significant bug in  Schedule_OnMonthCellLoadedEvent

                foreach (var item in appointments)
                {
                    Button button = new Button();
                    button.Text = (item as ScheduleAppointment).Subject;
                    button.BackgroundColor = Color.Blue;
                    button.TextColor = Color.White;
                    e.view = button;  // repeatedly replaces the entire view with a single button
                }


SG Swathi Gopal Syncfusion Team January 10, 2018 12:15 PM UTC

Hi Andy, 
 
Sorry for the inconvenience caused. 
 
We have modified the below mentioned sample, such that custom view for appointments is not repeatedly set in the MonthCellLoaded event, only the appointment text will be changed accordingly. Kindly find the modified sample below, 
 
Sample:  ScheduleForms
 
 
If the provided solution doesn’t meet your requirement, please revert us with more information so that we could provide you better solution.  
  
Regards, 
Swathi G 


Loader.
Up arrow icon