Appointments

Creating an Appointment

RadCalendar can display appointments by setting its AppointmentsSource property. It accepts a collection of objects, which should implement the Telerik.XamarinForms.IAppointment interface. This interface defines 6 members:

  • StartDate (DateTime)
  • EndDate (DateTime)
  • Title (string)
  • Detail (string)
  • Color (Color)
  • IsAllDay (bool)

In R2 2017 we have introduced a breaking change in the IAppointment interface by adding the Detail property.

Appointments Example

var date = new DateTime(2017, 4, 12);

var calendar = new RadCalendar
{
    DisplayDate = date,
    AppointmentsSource = new List<Appointment>{
        new Appointment {
            Title = "Meeting with Tom",
            Detail = "Sea Garden",
            StartDate = date.AddHours(1),
            EndDate = date.AddHours(2),
            Color = Color.Tomato
        },
        new Appointment {
            Title = "Lunch with Sara",
            Detail = "Restaurant",
            StartDate = date.AddHours(2).AddMinutes(30),
            EndDate = date.AddHours(3),
            Color = Color.DarkTurquoise
        },
        new Appointment {
            Title = "Birthday",
            StartDate = date.AddHours(2).AddMinutes(30),
            EndDate = date.AddHours(3),
            IsAllDay = true,
            Color = Color.Orange
        },
         new Appointment {
            Title = "Football Game",
            StartDate = date.AddDays(1).AddHours(2).AddMinutes(30),
            EndDate = date.AddDays(1).AddHours(3),
            Color = Color.Green
        }
    }
};

where Appointment class implements IAppointment interface:

public class Appointment : IAppointment
{
    public DateTime StartDate { get; set; }

    public Color Color { get; set; }

    public DateTime EndDate { get; set; }

    public string Title { get; set; }

    public bool IsAllDay { get; set; }

    public string Detail { get; set; }
}

Figure 1: Appearance of the RadCalendar control in month view mode

Appointments monthview

Figure 2: Appearance of the RadCalendar control in day view mode

Appointments dayview

Events

AppointmentTapped(AppointmentTappedEventArgs): Occurs when you tap over a specific appointment when in DayView mode. It can be used to get all the information regarding the appointment.

AppointmentTapped Example

First you need to set the ViewMode to Day:

calendar.NativeControlLoaded += (sender, e) =>
{
    calendar.TrySetViewMode(CalendarViewMode.Day);
};

Eventually, you can utilize the event:

calendar.AppointmentTapped += (sender, e) =>
{
    DisplayAlert(e.Appointment.Title, e.Appointment.Detail, "OK");
};

See Also