We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Add programmatically events to calendar

I would ask you how can I add/remove programmatically events to calendar.

In your samples, you add events in the constructor of AppointmentSource class, so I can load events ONLY when I load page.

How can I add/remove dinamically events with custom methods in AppointmentSource class?

Thanks you for the support,

8 Replies

BK Bharadhi K Syncfusion Team November 5, 2014 06:46 AM UTC

Hi Andrea,

Thank you for using Syncfusion Products.

We have prepared a sample in which we have tried to meet your requirements. In sample, we have added a button and in its click event we have added a new appointment for the selected date in the Calendar using “SelectedDate”  Property. Similarly we have added a button for removing the appointment for the Selected Date.

Please find the sample attached.

Bharadhi K

Attachment: SfCalendar_117522_42421573.zip

AG Andrea Grillo November 9, 2014 09:18 PM UTC

thank you for reply.

Now, I can add and remove item, but when I add something, the TransitionContentControl (list) doesn't show me any Appointments (only calendars shows title in the cell template).
I think that DataContext (or something like that) of TransitionContentControl must be refreshed, but I don't know how.

Can you help me, please?

Thank you again,

BK Bharadhi K Syncfusion Team November 10, 2014 12:16 PM UTC

Hi Andrea,

We have modified the sample in which we have tried to meet your requirements. In the sample, we have refreshed the SelectedDate of the Calendar while adding or removing an Appointment.
Please find the attached sample.

Bharadhi K

Attachment: SfCalendar_117522_cb45b877.zip

AG Andrea Grillo November 10, 2014 02:53 PM UTC

thank you for fastly response, but the problem persist.

As you can see in the zip file, when I tap on new user event ("Favorite movie with family" in my screenshots) the list at the bottom of calendar doesn't show it

How can I solve that?


screenshot1: "AppointmentSource" class
screenshot2: appointment loaded in constructor
screenshot3: no detailed information about appointment added in "AddAppointment" method

Attachment: calendar_43cbf8af.zip

BK Bharadhi K Syncfusion Team November 11, 2014 12:53 PM UTC

Hi Andrea,

We are unable to reproduce the issue in the sample which we had updated in the previous update. Could you please check if you have set the SelectedDate of the SfCalendar after you have added the Appointment as we had shown in the provided sample.

Please find the screenshots attached.
Screenshot1 - Appointment loaded in Constructor
ScreenShot2 - Appointment added by clicking the "Add Appointment on Selected Date" button.

Bharadhi K

Attachment: SfCalendar_8180e2f9.zip

AG Andrea Grillo November 11, 2014 10:05 PM UTC

My code seems ok. To be sure, I attached my code files (XAML and code behind).

Sorry for long discussion, I have to thank you!

Attachment: Code_a2bfef79.zip

BK Bharadhi K Syncfusion Team November 13, 2014 09:52 AM UTC

Hi Andrea,

The problem arose because the Resources have been defined for the Page but while refreshing the template, the code is set to get the Resources from App file. To resolve this, please remove the resources defined in MainPage.xaml and add it to the ResourceDictionary of App.xaml (This is done in the sample provided in the previous update).

We have also modified your code. Please find the modified code in the following link.

Bharadhi K

Attachment: Code_b36679d0.zip

AG Andrea Grillo November 13, 2014 08:06 PM UTC

It works fine!

Thank you very much for support me,
bye! :)

Live Chat Icon For mobile
Up arrow icon