I have a .Net MAUI app (target platform And, iOS & Win) im trying to use the SyncFusion Scheduler for the first time..
I have everything working but I'm struggling to obtain appointment details when I tap on the scheduler..
XAML:
<scheduler:SfScheduler x:Name="calendar" View="Month" FirstDayOfWeek="Monday" AllowedViews="Week ,Month"
TodayHighlightBrush="Gray" AppointmentsSource=" {Binding SchedulerEvents}" Tapped="calendar_Tapped" >
<scheduler:SfScheduler.MonthView>
<scheduler:SchedulerMonthView AppointmentDisplayMode="Indicator" />
</scheduler:SfScheduler.MonthView>
<scheduler:SfScheduler.BindingContext >
<local:SchedulerControlViewModel>
</local:SchedulerControlViewModel>
</scheduler:SfScheduler.BindingContext>
</scheduler:SfScheduler>
Code Behind:
private void calendar_Tapped(object sender, SchedulerTappedEventArgs e)
{
if (e.Appointments.Count < 0)
{
//No Appointment - no problem
}
else
{
//Appointment on date tapped
//// HOW DO I GET THE APPOINTMENT DETAILS FROM e.Appointments (such as the appointment subject.
}
}
View Model:
namespace MyGolfSocietyApp.ViewModels
{
public class SchedulerControlViewModel
{
public ObservableCollection<SchedulerAppointment> SchedulerEvents { get; set; }
public SchedulerControlViewModel()
{
this.SchedulerEvents = new ObservableCollection<SchedulerAppointment>
{
new SchedulerAppointment
{
StartTime = new DateTime(2023, 8, 5,00,01,01),
EndTime = new DateTime(2023, 8, 5,23,01,01),
Subject = "TEST Appointment",
IsAllDay = true
}
};
}
}
}
The Tapped event handler "calendar_Tapped" triggers ok but im struggling to get the content of the Appointments.. im sure this is super basic c# but im really struggling - hoping you guys can help me please
I can see through the debug logs (immediate window) data is being retunred from the View Model:
?e.Appointments
Count = 1
[0]: {Syncfusion.Maui.Scheduler.SchedulerAppointment}
?e.Appointments[0]
{Syncfusion.Maui.Scheduler.SchedulerAppointment}
base: {Syncfusion.Maui.Scheduler.SchedulerRegionBase}
ActualEndTime: {System.DateTime}
ActualStartTime: {System.DateTime}
DataItem: (null)
EndTimeZone: {System.TimeZoneInfo}
Id: 311937363
IsAllDay: true
IsReadOnly: false
Location: ""
Notes: ""
RecurrenceId: (null)
Reminders: (null)
StartTimeZone: {System.TimeZoneInfo}
Subject: "TEST Appointment"
Type: Syncfusion.Maui.Scheduler.SchedulerAppointmentType.Normal
Appointments
is a collection of object
public ReadOnlyCollection<object> Appointments { get; }
so you will need to cast it
((SchedulerAppointment)e.Appointments[0]).Subject