Scheduling UI Events
Since R3 2021 Service Pack Calendar's Scheduling UIs for Xamarin exposes events for appointments changes:
-
AppointmentAdded(AppointmentChangedEventAgrs): Occurs when appointment is added throught the Scheduling UI.
- The
sender
argument which is of type object, but can be cast to the RadCalendar type.- An
AppointmentChangedEventAgrs
object which provides the following properties: -
Appointment
property of type IAppointment and could be cast to the appointment implementation that is used in RadCalendar. -
Occurrence
property of type IExceptionOccurrence which gets the occurance. If the appointment is not recurrent, the value is null. -
OccurrenceAction
property of type OccurrenceAction which gets the action performed over the occurrence.
- An
- The
-
AppointmentUpdated(AppointmentChangedEventAgrs): Occurs when appointment is updated. The event is also raised for recurrent appointment when there is an action over the exception occurence - add/delete/update.
- The
sende
r argument which is of type object, but can be cast to the RadCalendar type.- An
AppointmentChangedEventAgrs
object which provides the following properties: -
Appointment
property of type IAppointment and could be cast to the appointment implementation that is used in RadCalendar. -
Occurrence
property of type IExceptionOccurrence which gets the occurance. If the appointment is not recurrent, the value is null. -
OccurrenceAction
property of type OccurrenceAction which gets the action performed over the occurrence.
- An
- The
The OccurrenceAction
enumeration specifies an action performed over an exception occurrence. The actions are:
-
None
: No action is performed over the exception occurrence of the recurrent appointment. -
Add
: When an exception occurence of the recurrent appointment is added. -
Update
: When an exception occurence of the recurrent appointment is updated. Delete
: When an exception occurence of the recurrent appointment is deleted.-
AppointmentDeleted(AppointmentChangedEventAgrs): Occurs when appointment is deleted.
- The
sender
argument which is of type object, but can be cast to the RadCalendar type. - An
AppointmentChangedEventAgrs
object which provides the following properties:-
Appointment
property of type IAppointment and could be cast to the appointment implementation that is used in RadCalendar. -
Occurrence
property of type IExceptionOccurrence which gets the occurance. If the appointment is not recurrent, the value is null. -
OccurrenceAction
of type OccurrenceAction which gets the action performed over the occurrence.
-
- The
In order to use these events, set
SchedulingUiEnabled
toTrue
.
Example
This example demonstrates a sample usage of appointment added, appointment updated and appointment deleted events. The ViewMode is set to MultiDayView.
Calendar definition in XAML:
<telerikInput:RadCalendar x:Name="calendar"
SchedulingUiEnabled="True"
ViewMode="MultiDay"
AppointmentAdded="CalendarAppointmentAdded"
AppointmentUpdated="CalendarAppointmentUpdated"
AppointmentDeleted="CalendarAppointmentDeleted">
<telerikInput:RadCalendar.MultiDayViewSettings>
<telerikInput:MultiDayViewSettings DayStartTime="8:00:00" />
</telerikInput:RadCalendar.MultiDayViewSettings>
</telerikInput:RadCalendar>
Events:
private void CalendarAppointmentAdded(object sender, AppointmentChangedEventAgrs e)
{
Application.Current.MainPage.DisplayAlert("Appointment Change", String.Format("Appointment with title `{0}` was created.", e.Appointment.Title), "OK");
}
private void CalendarAppointmentUpdated(object sender, AppointmentChangedEventAgrs e)
{
string notification;
switch(e.OccurrenceAction)
{
case OccurrenceAction.Add:
notification = String.Format("Exception occurence on {0:d} of the recurrent Appointment `{1}` was created.", e.Occurrence.ExceptionDate, e.Appointment.Title);
break;
case OccurrenceAction.Update:
notification = String.Format("Exception occurence on {0:d} of the recurrent Appointment `{1}` was updated.", e.Occurrence.ExceptionDate, e.Appointment.Title);
break;
case OccurrenceAction.Delete:
notification = String.Format("The occurence on {0:d} of the recurrent Appointment `{1}` was deleted.", e.Occurrence.ExceptionDate, e.Appointment.Title);
break;
default:
notification = String.Format("Appointment `{0}` was updated", e.Appointment.Title);
break;
}
Application.Current.MainPage.DisplayAlert("Appointment Change", notification, "OK");
}
private void CalendarAppointmentDeleted(object sender, AppointmentChangedEventAgrs e)
{
Application.Current.MainPage.DisplayAlert("Appointment Change", String.Format("Appointment with title `{0}` was deleted.", e.Appointment.Title), "OK");
}