Reminder in WinUI Scheduler (SfScheduler)
22 Jul 202610 minutes to read
The WinUI Scheduler notifies an appointment reminder by using the ReminderAlertOpening event. An appointment can have one or more reminders.
Enable reminder
A reminder can be enabled by setting the EnableReminder property to true, which is used to trigger the ReminderAlertOpening event to notify the appointment reminder. The reminder can be set by using the Reminders property of ScheduleAppointment.
<Window
...
xmlns:scheduler="using:Syncfusion.UI.Xaml.Scheduler">
<scheduler:SfScheduler x:Name="Scheduler"
ViewType="Week"
EnableReminder="True" >
</scheduler:SfScheduler>
</Window>Adding reminders
Configure the appointment reminders with SchedulerReminder. The SchedulerReminder has the following properties.
| Properties | Description |
|---|---|
| Gets or sets the time interval that decides to notify the reminder before the appointment's start time. | |
| Gets the reminder time that decides when to enable `ReminderAlertOpening` event to the reminder of the appointment. | |
| Gets the appointment details for which the reminder is created. | |
| Gets the reminder data object associated with the `SchedulerReminder.` | |
| Gets or sets whether the reminder is dismissed. |
<Window
...
xmlns:scheduler="using:Syncfusion.UI.Xaml.Scheduler">
<Grid.DataContext>
<local:ReminderViewModel/>
</Grid.DataContext>
<scheduler:SfScheduler x:Name="Schedule"
ItemsSource="{Binding Events}"
EnableReminder="True">
</scheduler:SfScheduler>
</Window>using Syncfusion.UI.Xaml.Scheduler;
public class ReminderViewModel
{
...
public ScheduleAppointmentCollection Events { get; set; } = new ScheduleAppointmentCollection();
public ReminderViewModel()
{
this.Events.Add(new ScheduleAppointment()
{
StartTime = DateTime.Now,
EndTime = DateTime.Now.AddHours(1),
AppointmentBackground = new SolidColorBrush(Color.FromArgb(255, 83, 99, 250)),
Subject = "Conference",
Reminders = new ObservableCollection<SchedulerReminder>
{
new SchedulerReminder { ReminderTimeInterval = new TimeSpan(0)},
}
});
}
}Creating business object for reminder
Reminders supports mapping the custom object with the ScheduleAppointment.Reminders.
using Syncfusion.UI.Xaml.Scheduler;
/// <summary>
/// Represents custom data properties.
/// </summary>
public class Event
{
public Event()
{
}
public DateTime From { get; set; }
public DateTime To { get; set; }
public bool IsAllDay { get; set; }
public string EventName { get; set; }
public string Notes { get; set; }
public string StartTimeZone { get; set; }
public string EndTimeZone { get; set; }
public Brush Color { get; set; }
public object RecurrenceId { get; set; }
public object Id { get; set; }
public string RecurrenceRule { get; set; }
public ObservableCollection<DateTime> RecurrenceExceptions { get; set; }
public ObservableCollection<Reminder> Reminders { get; set; }
}The ReminderMapping provides the mapping information about the SchedulerReminder properties to the Data object. ReminderMapping has the following properties,
- ReminderTimeInterval: Maps the property name of a custom class, which is equivalent for the SchedulerReminder.ReminderTimeInterval.
- IsDismissed: Maps the property name of a custom class, which is equivalent for the SchedulerReminder.IsDismissed.
- ReminderAlertTime: Maps the property name of a custom class, which is equivalent for the SchedulerReminder.ReminderAlertTime.
using Syncfusion.UI.Xaml.Scheduler;
/// <summary>
/// Represents custom data properties.
/// </summary>
public class Reminder
{
/// <summary>
/// Gets or sets the value indicating whether the reminder is dismissed or not.
/// </summary>
public bool Dismissed { get; set; }
/// <summary>
/// Gets or sets a value that decides to notify the reminder before the appointment’s start time.
/// </summary>
public TimeSpan TimeInterval { get; set; }
}Map those properties of the Meeting class with the SfScheduler control by using the AppointmentMapping and map CustomReminder properties with the SchedulerReminder by using the ReminderMapping.
<Window
...
xmlns:scheduler="using:Syncfusion.UI.Xaml.Scheduler">
<scheduler:SfScheduler x:Name="Schedule"
ItemsSource="{Binding Events}"
EnableReminder="True">
<scheduler:SfScheduler.AppointmentMapping>
<scheduler:AppointmentMapping
Subject="EventName"
StartTime="From"
EndTime="To"
AppointmentBackground="Color"
IsAllDay="IsAllDay"
StartTimeZone="StartTimeZone"
EndTimeZone="EndTimeZone"
RecurrenceExceptionDates="RecurrenceExceptions"
RecurrenceRule="RecurrenceRule"
RecurrenceId="RecurrenceId"
Reminders="Reminders">
<scheduler:AppointmentMapping.ReminderMapping>
<scheduler:ReminderMapping IsDismissed="Dismissed"
ReminderTimeInterval="TimeInterval"/>
</scheduler:AppointmentMapping.ReminderMapping>
</scheduler:AppointmentMapping>
</scheduler:SfScheduler.AppointmentMapping>
</scheduler:SfScheduler>
</Window>using Syncfusion.UI.Xaml.Scheduler;
public class ReminderViewModel
{
...
public ObservableCollection<Event> Events { get; set; } = new ObservableCollection<Event>();
public ReminderViewModel()
{
this.Events.Add(new Event()
{
From = DateTime.Now,
To = DateTime.Now.AddHours(1),
Color = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF339933")),
EventName = "Conference",
Reminders = new ObservableCollection<Reminder>
{
new Reminder { TimeInterval = new TimeSpan(0)},
}
});
}
}ReminderAlertOpening event
The Scheduler notifies the appointment’s reminder by the ReminderAlertOpening event before the appointment’s start time. The ReminderAlertOpeningEventArgs has the following properties:
- Reminders: Gets a list of reminders that are used to notify the appointment reminders.
-
Cancel: Cancels the reminder notification by setting this property totrue.
using Syncfusion.UI.Xaml.Scheduler;
scheduler.ReminderAlertOpening += Scheduler_ReminderAlertOpening;
private void Scheduler_ReminderAlertOpening(object sender, ReminderAlertOpeningEventArgs e)
{
var reminders = e.Reminders;
var appointment = e.Reminders[0].Appointment;
}