Articles in this section

Customize the week number and day using DataTemplate in WinUI.

The ShowWeekNumbers property in the WinUI Calendar (SfCalendar) can be used to display the week number of the month; by default, ShowWeekNumbers is set to false. Also, you can customize the week number by using WeekNameTemplate and the weekday name by using the WeekNumberTemplate of the CalendarItemTemplateSelector.

XAML

<Window
    x:Class="CalendarItemTemplateSelector.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:CalendarItemTemplateSelector"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:calendar="using:Syncfusion.UI.Xaml.Calendar">
 
    <Grid>
        <Grid.Resources>
            <DataTemplate x:Key="WeekNameAndNumberTemplate">
                <Viewbox >
                    <Grid>
                        <Ellipse Width="30" 
                                Height="30" 
                                Fill="WhiteSmoke"
                                HorizontalAlignment="Center" VerticalAlignment="Center"
                                Margin="1" />
                        <TextBlock Text="{Binding DisplayText}" 
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center" 
                                Foreground="DeepSkyBlue"/>
                    </Grid>
                </Viewbox>
            </DataTemplate>
        </Grid.Resources>
        <calendar:SfCalendar 
                         ShowWeekNumbers="True">
            <calendar:SfCalendar.Resources>
                <Style TargetType="calendar:CalendarItem">
                    <Setter Property="ContentTemplateSelector">
                        <Setter.Value>
                            <calendar:CalendarItemTemplateSelector WeekNameTemplate="{StaticResource WeekNameAndNumberTemplate}" 
                                                                WeekNumberTemplate="{StaticResource WeekNameAndNumberTemplate}" />
                        </Setter.Value>
                    </Setter>
                </Style>
            </calendar:SfCalendar.Resources>
        </calendar:SfCalendar>
    </Grid>
 
</Window>

 

View sample in GitHub.

WINUI Calendar week number customization

Conclusion

I hope you enjoyed learning about how to customize the week number and day using  DataTemplate in WinUI.

You can refer to our  WinUI Calendar feature tour page to know about its other groundbreaking feature representations. You can also explore our WinUI Calendar documentation 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 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)
Access denied
Access denied