Articles in this section
Category / Section

How to add blackout dates in the .NET MAUI Scheduler (SfScheduler)?

4 mins read

In the .NET MAUI Scheduler, you can add specific dates as blackout dates with the help of the SelectableDayPredicate function. Blackout dates are restricted from the selection. Additionally, you can customize the blackout date's style using the DisableDateBackground and DisableDateTextStyle properties of the scheduler.


XAML

Initialize the scheduler with the required properties.

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="BlackoutDates.MainPage"
             BackgroundColor="{DynamicResource SecondaryColor}"
             xmlns:scheduler="clr-namespace:Syncfusion.Maui.Scheduler;assembly=Syncfusion.Maui.Scheduler">
    <Grid>
    <scheduler:SfScheduler x:Name="Scheduler" View="Week" AllowedViews="Day,Week,WorkWeek,Month,TimelineMonth "/>
  </Grid>
</ContentPage>

CS

By using the SelectableDayPredicate function, you can add required dates as blackout dates.

public MainPage()
{
    InitializeComponent();
    this.Scheduler.SelectableDayPredicate = (date) =>
    {
        if (date.DayOfWeek == DayOfWeek.Sunday || date.DayOfWeek == DayOfWeek.Saturday)
        {
            return false;
        }
 
        return true;
    };
    var disabledDateTextStyle = new SchedulerTextStyle()
    {
        TextColor = Colors.Red,
        FontSize = 12,
    };
 
    this.Scheduler.DisabledDateTextStyle = disabledDateTextStyle;
    this.Scheduler.DisabledDateBackground = Brush.LightSkyBlue;
 
}

 Output

 

Month View

Week view

MAUI Scheduler month blackout dates.

MAUI Scheduler week blackout dates.

 

Conclusion

I hope you enjoyed learning how to add blackout dates in the .NET MAUI Scheduler.

Refer to our .NET MAUI Scheduler feature tour page to learn about its other groundbreaking feature representations. You can explore our .NET MAUI Scheduler 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 Scheduler 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 forumsDirect-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