Date Navigation in Xamarin Calendar (SfCalendar)
12 May 20212 minutes to read
SfCalendar control provides the option to navigate through items either programmatically or by using gestures.
By using the following methods, we can navigate the months or year in
SfCalendar with programmatically without applying gesture.
By default, the date can be navigated to next view using touch gesture and swiping the control in right to left direction. The view can also be changed programmatically using Forward method available in
SfCalendar. It will move to next month,next year,next period of decade years,next period of century years based on the
It can be navigated until it reaches the MaxDate.
By default, the date can be navigated to previous view using touch gesture and swiping the control in left to right direction. The view can also be changed programmatically using Backward method available in
SfCalendar. It will move to previous month,previous year,previous period of decade years,previous period century years based on the
It can be navigated until it reaches the MinDate.
Move to Date
Visible dates can be moved to specific date using MoveToDate property available in
SfCalendar. it will move to any specific month,year,decade,century view based on the
The specified date should lie between MinDate and MaxDate, if the specified date is greater than MaxDate then the view will be moved to MaxDate and if the specified date is lesser than the MinDate then the view will be moved to MinDate.
SfCalendar calendar = new SfCalendar(); calendar.MoveToDate = new DateTime(2017,5,5); this.Content = calendar;
You can navigate the calendar
Horizontal directions by setting the NavigationDirection.
SfCalendar calendar = new SfCalendar(); Calendar.NavigationDirection = NavigationDirection.Vertical;
Visible dates can be moved to a specific date using the NavigateTo method available in SfCalendar.It will move to any specific date of the month if the calendar view is Month View.
DateTime currentDate = DateTime.Now; DateTime SpecificDate = new DateTime(currentDate.Year - 5,currentDate.Month - 3, currentDate.Day, 0, 0, 0); calendar.NavigateTo(SpecificDate);