How to change the display text of the WinUI Calendar (SfCalendar) dates
In WINUI Calendar, you can change the calendar dates view display text by using the ItemPrepared event of the calendar.
XAML
<Window
x:Class="Custom_LeadTrailDates.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Custom_LeadTrailDates"
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">
<calendar:SfCalendar x:Name="calendar"
CornerRadius="14"
DayOfWeekFormat="{}{dayofweek.abbreviated(3)}">
</calendar:SfCalendar>
</Window>
C#
Here shown is how to change the display text for the leading and trailing dates view by using the DateInfo parameter.
public sealed partial class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();
calendar.ItemPrepared += Calendar_ItemPrepared;
}
private void Calendar_ItemPrepared(object sender, Syncfusion.UI.Xaml.Calendar.CalendarItemPreparedEventArgs e)
{
if (e.ItemInfo.DateInfo.HasFlag(Syncfusion.UI.Xaml.Calendar.CalendarDateInfo.OutOfScope))
{
e.ItemInfo.DisplayText = "x";
}
}
}
