Articles in this section
Category / Section

How to Disable the User Interaction in the .NET MAUI Calendar (SfCalendar)?

3 mins read

In the Syncfusion .NET MAUI Calendar, disable the user interaction of specified dates using the SelectableDayPredicate property of the SfCalendar.

 

Step 1: Add the SfCalendar control to your layout.

 

XAML

<calendar:SfCalendar x:Name="calendar" />

 

Step 2: Use the SelectableDayPredicate property to disable a specified date which prevents user interaction with that particular date as shown in the following code sample.

 

C#

this.calendar.SelectableDayPredicate = (date) =>
{
    if (date.Date == DateTime.Now.AddDays(1).Date || date.Date == DateTime.Now.AddDays(3).Date || date.Date == DateTime.Now.AddDays(5).Date
    || date.Date == DateTime.Now.AddDays(7).Date || date.Date == DateTime.Now.AddDays(9).Date)
    {
        return false;
    }
 
    return true;
};

 

Step 3: Customize the appearance of the disabled dates if needed using the DisabledDatesBackground and DisabledDatesTextStyle properties of the SfCalendar’s MonthView as shown in the following code sample.

 

C#

this.calendar.MonthView.DisabledDatesBackground = Color.FromArgb("#ECECEC");
this.calendar.MonthView.DisabledDatesTextStyle = new CalendarTextStyle()
{
    TextColor = Colors.Gray,
};

 

 

Output:

 

Disable user interaction in Syncfusion .NET MAUI Calendar

 

Conclusion

I hope you enjoyed learning how to disable user interaction 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!

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