How to customize .NET MAUI Scheduler Days View?
The .NET MAUI Scheduler allows customization of the days view header in the day, week, workweek, month, and timeline views through the ViewHeaderTemplate property of the DaysView, TimelineView, and MonthView.
The BindingContext of the ViewHeaderTemplate is System.DateTime.
STEP 1:
Define a DataTemplate to customize the appearance of the timeline view header.
<DataTemplate x:Key="timelineViewHeaderTemplate">
<Grid x:Name="grid" Background="MediumPurple" >
<Label x:Name="label" HorizontalOptions="Start" VerticalOptions="Center" TextColor="White" >
<Label.Text>
<MultiBinding StringFormat = "{}{0:dd} {1:ddd}" >
<Binding />
<Binding />
</MultiBinding >
</Label.Text >
<Label.Triggers >
<DataTrigger TargetType="Label" Binding="{Binding}" Value="{x:Static system:DateTime.Today}">
<Setter TargetName = "label" Property="TextColor" Value="Orange"/>
</DataTrigger>
</Label.Triggers>
</Label>
<Grid.Triggers>
<DataTrigger TargetType = "Grid" Binding="{Binding}" Value="{x:Static system:DateTime.Today}">
<Setter TargetName = "grid" Property="Background" Value="LightGreen"/>
</DataTrigger>
</Grid.Triggers>
</Grid>
</DataTemplate>
STEP 2:
Define another DataTemplate for the day, week, workweek, and month view header.
<DataTemplate x:Key="viewHeaderTemplate">
<StackLayout x:Name="stackLayout" Orientation="Vertical" Background="MediumPurple">
<Label x:Name="label" HorizontalOptions="Center" VerticalOptions="Center" Text="{Binding StringFormat='{0:dd}'}" FontSize="Small" FontFamily="Bold" TextColor="White" >
<Label.Triggers>
<DataTrigger TargetType = "Label" Binding="{Binding}" Value="{x:Static system:DateTime.Today}">
<Setter TargetName = "label" Property="TextColor" Value="Orange"/>
</DataTrigger>
</Label.Triggers>
</Label>
<Label x:Name="label1" HorizontalOptions="Center" VerticalOptions="Center" Text="{Binding StringFormat='{0:ddd}'}" FontSize="Small" FontFamily="Bold" TextColor="White">
<Label.Triggers>
<DataTrigger TargetType = "Label" Binding="{Binding}" Value="{x:Static system:DateTime.Today}">
<Setter TargetName = "label1" Property="TextColor" Value="Orange"/>
</DataTrigger>
</Label.Triggers>
</Label>
<StackLayout.Triggers>
<DataTrigger TargetType = "StackLayout" Binding="{Binding}" Value="{x:Static system:DateTime.Today}">
<Setter TargetName = "stackLayout" Property="Background" Value="MediumPurple"/>
</DataTrigger>
</StackLayout.Triggers>
</StackLayout>
</DataTemplate>
STEP 3:
Assign the templates to appropriate views in the scheduler.
<scheduler:SfScheduler x:Name="Scheduler"
View="Month" AllowedViews="Day,Week,WorkWeek,TimelineDay,TimelineWeek,TimelineWorkWeek, TimelineMonth">
<scheduler:SfScheduler.DaysView>
<scheduler:SchedulerDaysView ViewHeaderTemplate="{StaticResource viewHeaderTemplate}"
/>
</scheduler:SfScheduler.DaysView>
<scheduler:SfScheduler.TimelineView>
<scheduler:SchedulerTimelineView ViewHeaderTemplate="{StaticResource timelineViewHeaderTemplate}"/>
</scheduler:SfScheduler.TimelineView>
<scheduler:SfScheduler.MonthView>
<scheduler:SchedulerMonthView ViewHeaderTemplate="{StaticResource viewHeaderTemplate}"/>
</scheduler:SfScheduler.MonthView>
</scheduler:SfScheduler>
Download the complete sample on GitHub
Conclusion
I hope you enjoyed learning how to customize the .NET MAUI Scheduler days view.
You can refer to our .NET MAUI Scheduler feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. Explore our .NET MAUI Scheduler example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!