Skip to content

Latest commit

 

History

History
55 lines (43 loc) · 2.23 KB

README.md

File metadata and controls

55 lines (43 loc) · 2.23 KB

How to navigate to the specific month in Xamarin.Forms Calendar (SfCalendar)

Visible dates can be moved to specific date using MoveToDate property available in SfCalendar. It is applicable for all the ViewMode.

You can also refer the following article.

https://www.syncfusion.com/kb/11832/how-to-navigate-to-the-specific-month-in-xamarin-forms-calendar-sfcalendar

STEP 1: Create a ViewModel class and add a MoveToDate property with specific date.

public class ViewModel : INotifyPropertyChanged
{
   public event PropertyChangedEventHandler PropertyChanged;

   private DateTime moveToDate = new DateTime(2010, 10, 12);

   public DateTime MoveToDate
   {
     get
     {
          return this.moveToDate;
     }
     set
     {
          this.moveToDate = value;
          this.OnPropertyChanged("MoveToDate");
     }
   }

   public ViewModel()
   {
   }

   private void OnPropertyChanged(string propertyName)
   {
                this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
   }
}

STEP 2: Bind the MoveToDate ViewModel property to the MoveToDate property of SfCalendar.

<calendar:SfCalendar x:Name="calendar"
                             DataSource="{Binding Appointments}"
                             MoveToDate="{Binding MoveToDate}">
            <calendar:SfCalendar.BindingContext>
                <local:ViewModel/>
            </calendar:SfCalendar.BindingContext>
</calendar:SfCalendar>

Output

MoveToDate