How to get Datetime Details in the .NET MAUI Calendar (SfCalendar)?
In the Syncfusion® .NET MAUI Calendar control, you can retrieve the DateTime details of a specific date using the Tapped event of SfCalendar.
Using the DisplayAlert() method inside the Tapped event, you can display the details of the tapped date.
XAML
<calendar:SfCalendar x:Name="calendar"> <calendar:SfCalendar.Behaviors> <local:CalendarBehavior /> </calendar:SfCalendar.Behaviors> </calendar:SfCalendar>
C#
public class CalendarBehavior : Behavior<SfCalendar> { private SfCalendar calendar; protected override void OnAttachedTo(SfCalendar bindable) { base.OnAttachedTo(bindable); this.calendar = bindable; this.calendar.Tapped += calendar_Tapped; } private void calendar_Tapped(object sender, CalendarTappedEventArgs e) { App.Current.MainPage.DisplayAlert("Tapped date details", e.Date.ToString("dddd, dd MMMM yyyy"), "OK"); } protected override void OnDetachingFrom(SfCalendar bindable) { base.OnDetachingFrom(bindable); if (this.calendar != null) { this.calendar.Tapped -= calendar_Tapped; } this.calendar = null; } }
Download the complete sample on GitHub
Output:
Conclusion
I hope you enjoyed learning how to get Datetime details by tapping on the .NET MAUI Calendar (SfCalendar).
You can refer to our .NET MAUI Calendar’s feature tour page to know about its other groundbreaking feature representations. Explore our .NET MAUI Calender documentation to understand how to present and manipulate data.
For current customers, you can check out our .NET MAUI 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 .NET MAUI Calendar and other .NET MAUI components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!