How to Customize Special Dates in the .NET MAUI Calendar (SfCalendar)?
In the Syncfusion .NET MAUI Calendar control, customize the special dates in the SfCalendar’s MonthView using the following steps.
Step 1: Create a ViewModel class and add the SpecialDatesList property to specify the special dates and bind that property into the CalendarMonthView’s SpecialDates property of the SfCalendar as shown in the following code sample.
C#
public class CalendarViewModel { public List<DateTime> SpecialDatesList { get; set; } public CalendarViewModel() { this.SpecialDatesList = new List<DateTime>() { DateTime.Now.AddDays(3), DateTime.Now.AddDays(6), DateTime.Now.AddDays(8), DateTime.Now.AddDays(-2), DateTime.Now.AddDays(-4), DateTime.Now.AddDays(-6), }; } }
XAML
<ContentPage.BindingContext> <local:CalendarViewModel /> </ContentPage.BindingContext> <ContentPage.Content> <calendar:SfCalendar x:Name="calendar"> <calendar:SfCalendar.MonthView> <calendar:CalendarMonthView SpecialDates="{Binding SpecialDatesList}"> </calendar:CalendarMonthView> </calendar:SfCalendar.MonthView> </calendar:SfCalendar> </ContentPage.Content>
Step 2: Change the background color of the special dates using the SpecialDatesBackground property of the SfCalendar’s CalendarMonthView as shown in the following code sample.
XAML
<calendar:CalendarMonthView SpecialDates="{Binding SpecialDatesList}" SpecialDatesBackground="#C9BDF2"> </calendar:CalendarMonthView>
Step 3: Change the special dates text style using the SpecialDatesTextStyle’s CalendarTextStyle properties: TextColor, FontSize, FontFamily, and FontAttributes.
XAML
<calendar:CalendarMonthView SpecialDates="{Binding SpecialDatesList}" SpecialDatesBackground="#C9BDF2"> <calendar:CalendarMonthView.SpecialDatesTextStyle> <calendar:CalendarTextStyle TextColor="Red" FontAttributes="Bold,Italic" FontSize="20" /> </calendar:CalendarMonthView.SpecialDatesTextStyle> </calendar:CalendarMonthView>
Output:
Conclusion
I hope you enjoyed learning how to customize the special dates in the .NET MAUI Calendar (SfCalendar).
Refer to our .NET MAUI Calendar’s feature tour page to learn about its other groundbreaking feature representations. You can explore our .NET MAUI Calendar documentation to understand how to present and manipulate data.
For current customers, check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion, try our 30-day free trial to check out our .NET MAUI Calendar and other .NET MAUI components.
Please let us know in the following comments section if you have any queries or require clarifications. Contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!