Articles in this section

How to Navigate to Inactive Months in the .NET MAUI Calendar (SfCalendar)?

In the Syncfusion® .NET MAUI Calendar control, you can navigate to the inactive month by tapping on the inactive month’s date of SfCalendar using the SelectionChanged event.

 

Step 1: Add the SfCalendar control to your layout, as shown in the following code sample.

 

XAML

<calendar:SfCalendar x:Name="calendar">
    <calendar:SfCalendar.Behaviors>
        <local:CalendarBehavior />
    </calendar:SfCalendar.Behaviors>
</calendar:SfCalendar>

 

Step 2: Use the SelectionChanged event of SfCalendar to navigate to an inactive month when a date is tapped, as demonstrated in the following code sample.

 

C#

public class CalendarBehavior : Behavior<SfCalendar>
{
    private SfCalendar sfCalendar;
 
    protected override void OnAttachedTo(SfCalendar bindable)
    {
        base.OnAttachedTo(bindable);
        this.sfCalendar = bindable;
        this.sfCalendar.SelectionChanged += SfCalendar_SelectionChanged;
    }
 
    private void SfCalendar_SelectionChanged(object sender, CalendarSelectionChangedEventArgs e)
    {
        DateTime tappedDate = DateTime.Parse(e.NewValue.ToString());
        if (tappedDate.Month != sfCalendar.DisplayDate.Month)
        {
            sfCalendar.DisplayDate = tappedDate;
        }
    }
 
    protected override void OnDetachingFrom(SfCalendar bindable)
    {
        base.OnDetachingFrom(bindable);
        if (this.sfCalendar != null)
        {
            this.sfCalendar.SelectionChanged -= SfCalendar_SelectionChanged;
        }
 
        this.sfCalendar = null;
    }
}

 

Download the complete sample on GitHub

 

Output:

 

Inactive month navigation using Syncfusion .NET MAUI Calendar

 

Conclusion

 

I hope you enjoyed learning how to navigate to the inactive month by tapping on the inactive month’s date in 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 Calendar 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!

 

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