Articles in this section

How to get the selected date from the WinUI Calendar (SfCalendar)

In the WinUI Calendar (SfCalendar), you can get the selected date by using the SelectedDateChanged event of the calendar.

XAML

<Window
    x:Class="SelectedDate.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:SelectedDate"
    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>
        <TextBlock x:Name="text" Text="" TextAlignment="Center"/>
        <calendar:SfCalendar Name="Calendar" SelectedDateChanged="Calendar_SelectedDateChanged"/>
    </Grid>
</Window>

CS

In the following code sample, the calendar selected date value is displayed in text block control by using the SelectedDateChanged event of the calendar.

private void Calendar_SelectedDateChanged(object sender, Syncfusion.UI.Xaml.Calendar.SelectedDateChangedEventArgs e)
{
    this.text.Text = "Selected date: " + e.NewDate.Value.ToString("dd/yyyy/MMMM");
}

View sample in GitHub.

Calendar selected date

 

 

 

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