How to create monthly recurrence appointments in WinUI Scheduler (Calendar)
Add the monthly recurrence appointment to the WinUI SfScheduler with the help of RecurrenceRule.
Please refer to the user guide documentation for the recurrence property and its purpose.
C#
Create the recurrence appointment in the ViewModel with the help of RecurrenceRule.
public class SchedulerViewModel : INotifyPropertyChanged
{
private ScheduleAppointmentCollection scheduleAppointmentCollection;
public SchedulerViewModel()
{
this.ScheduleAppointmentCollection = new ScheduleAppointmentCollection();
var scheduleAppointment = new ScheduleAppointment()
{
Id = 1,
StartTime = DateTime.Today.AddHours(11),
EndTime = DateTime.Today.AddHours(12),
Subject = "Occurs Monthly on 15th",
};
scheduleAppointment.RecurrenceRule = "FREQ=MONTHLY;BYMONTHDAY=15;INTERVAL=1;COUNT=10";
ScheduleAppointmentCollection.Add(scheduleAppointment);
}
public ScheduleAppointmentCollection ScheduleAppointmentCollection
{
get
{
return this.scheduleAppointmentCollection;
}
set
{
this.scheduleAppointmentCollection = value;
this.RaiseOnPropertyChanged("ScheduleAppointmentCollection");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void RaiseOnPropertyChanged(string propertyName)
{
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
XAML
Binding the ScheduleAppointmentCollection to the Scheduler.
<scheduler:SfScheduler x:Name="Schedule"
FirstDayOfWeek="Monday"
ViewType="Month"
ItemsSource="{Binding ScheduleAppointmentCollection}">
</scheduler:SfScheduler>