Articles in this section
Category / Section

How to style the month cell using MonthCellLoaded event in Xamarin.Forms Calendar (SfCalendar)

You can style the month cell using the OnMonthCellLoaded event of SfCalendar in Xamarin.Forms.

 

C#

By using the OnMonthCellLoaded  you can customize the Text, BackgroudColor, BorderColor and Font by using the MonthCellLoadedEventArgs argument

this.calendar.OnMonthCellLoaded += Calendar_OnMonthCellLoaded;
 
private void Calendar_OnMonthCellLoaded(object sender, MonthCellLoadedEventArgs args)
{
   // As default setting Month cell Background color as Green 
   args.BackgroundColor = Color.Green;
   var appointments = calendar.DataSource as CalendarEventCollection;
 
   for (int i = 0; i < appointments.Count; i++)
    {
        var appointment = appointments[i];
        if (args.Date.Date == appointment.StartTime.Date)
          {
           // Setting Background color when the appointment available on the specific day 
           args.BackgroundColor = Color.Red;
          }
    }
}

Output

Custom Cell

View Sample in GitHub

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied