0

I have a page that contains a Syncfusion weekly SfSchedule when I try to open the page it gives me this error:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation and the InnerException is: {System.ArgumentOutOfRangeException}. The App crashes on InitializeComponent(); line.

The I'm filling the data source of the schedule from my realm database.

This is the XAML code:

<ContentPage.Padding>
   <OnPlatform x:TypeArguments="Thickness"
             iOS="0, 20, 0, 0"
             Android="0"
             WinPhone="0" />
 </ContentPage.Padding>

<ContentPage.BindingContext>
  <ViewModels:ActivitiesViewModel/>
</ContentPage.BindingContext>

<WeeklySchedule:SfSchedule x:Name="activitiesWeeklySchedule"
                      BackgroundColor="White"
                      HorizontalOptions="FillAndExpand"
                      VerticalOptions="FillAndExpand"
                      ScheduleView="WeekView"
                      ShowAppointmentsInline="True">
</WeeklySchedule:SfSchedule>

And this is the code behind:

    Realm realm;
    ScheduleAppointmentCollection collection;
    public TeacherWeeklyView() {
        InitializeComponent();
        collection = new ScheduleAppointmentCollection() { };
        var config = new RealmConfiguration() { SchemaVersion = 3 };
        realm = Realm.GetInstance(config);
        var activities = realm.All<ActivitiesItems>();
        foreach (var item in activities) {
           System.Diagnostics.Debug.WriteLine(item.ActivitySubject);
           collection.Add(activity);
        }
        activitiesWeeklySchedule.DataSource = collection;
     }

This problem started when the Syncfusion packages needed to be updated so I updated it but nothing has changed.

Quality Catalyst
  • 6,531
  • 8
  • 38
  • 62
Mireille
  • 637
  • 2
  • 12
  • 27

1 Answers1

0

I fixed it I deleted this part of code:

<ContentPage.BindingContext>
   <ViewModels:ActivitiesViewModel/>
</ContentPage.BindingContext>
Mireille
  • 637
  • 2
  • 12
  • 27