Category / Section
How to style the month cell using MonthCellLoaded event in Xamarin.Forms Calendar (SfCalendar)
1 min read
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