Skip to content

This repository contains a sample on How to bind events in the Syncfusion Xamarin.Forms Calendar (SfCalendar) using FreshMVVM framework?

Notifications You must be signed in to change notification settings

SyncfusionExamples/fresh-mvvm-calendar-xamarin-forms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

How to bind events in Xamarin.Forms Calendar (SfCalendar) using FreshMVVM framework

The SfCalendar allows you to work with FreshMVVM framework. To achieve this, follow the below steps.

The following article explains about working with FreshMVVM framework https://www.syncfusion.com/kb/11228/how-to-bind-events-in-xamarin-forms-calendar-sfcalendar-using-freshmvvm-framework

Step 1: Install the FreshMVVM NuGet package in your shared code project.

Step 2: Create your XAML page (view) with name ending with “Page”.

namespace CalendarXamarin
{
    public partial class CalendarPage : ContentPage
    {
         public CalendarPage ()
         {
            InitializeComponent ();
         }
    }
}

Step 3: Create a page model with the name ending with PageModel and inherit FreshBasePageModel. If your Page name is MainPage then the PageModel name should be MainPageModel and the namespace of Page and PageModel should be the same.

namespace CalendarXamarin
{
     public class CalendarPageModel : FreshBasePageModel
     {
        
     }
}

To raise property changed notifier, use RaisePropertyChanged method of base class in your PageModel.

public class CalendarPageModel : FreshBasePageModel
{
      private CalendarEventCollection appointments;
 
      public CalendarEventCollection Appointments
      {
           get
           {
                return this.appointments;
           }
           set
           {
                this.appointments = value;
                this.RaisePropertyChanged("Appointments");
           }
      }
 
      public CalendarPageModel()
      {
           this.Appointments = new CalendarEventCollection();
      }
}

Step 4: Set MainPage using PageModel in your App.xaml.cs file.

public partial class App : Application
{
      public App()
      {
          InitializeComponent();
 
          var page = FreshPageModelResolver.ResolvePageModel<CalendarPageModel>();
          var basicNavContainer = new FreshNavigationContainer(page);
          MainPage = basicNavContainer;
      }
}

Step 5: Bind the event collection to the Calendar DataSource without mentioning the binding context.

<syncfusion:SfCalendar x:Name="calendar" 
                               DataSource="{Binding Appointments}" 
                               ShowInlineEvents="True"/>

About

This repository contains a sample on How to bind events in the Syncfusion Xamarin.Forms Calendar (SfCalendar) using FreshMVVM framework?

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages