Reminder in WinUI Scheduler (SfScheduler)

12 Apr 20229 minutes to read

The WinUI scheduler notify an appointment reminder by using the ReminderAlertOpening event. An appointment can have one or more reminders.

Enable reminder

Reminder can be enable by setting the EnableReminder property to true which is used to trigger the ReminderAlertOpening event to notify appointment reminder. The reminder can be set by using the Reminders property of ScheduleAppointment.

<syncfusion:SfScheduler x:Name="Scheduler"
                        ViewType="Week"
                        EnableReminder="True" >
</syncfusion:SfScheduler>

Adding reminders

Configure the appointment reminders with SchedulerReminder. The SchedulerReminder has the following properties.

Properties Description

ReminderTimeInterval

Gets or sets the time interval that decides to notify the reminder before the appointment’s start time.

ReminderAlertTime

Gets the reminder time that decides when to enable `ReminderAlertOpening` event to the reminder of the appointment.

Appointment

Gets the appointment details for which the reminder is created.

Data

Gets the reminder data object associated with the `SchedulerReminder.`

IsDismissed

Gets or sets whether the reminder is dismissed.
<Grid.DataContext>
    <local:ReminderViewModel/>
 </Grid.DataContext>
 <syncfusion:SfScheduler x:Name="Schedule" 
                ItemsSource="{Binding Events}"
                EnableReminder="True">
  </syncfusion:SfScheduler>
public class ReminderViewModel 
 {
    ...
    public ScheduleAppointmentCollection Events { get; set; } = new ScheduleAppointmentCollection();
    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 to map the custom object with the ScheduleAppointment.Reminders.

/// <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,

/// <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.

<syncfusion:SfScheduler x:Name="Schedule" 
                ItemsSource="{Binding Events}"
                EnableReminder="True">
            <syncfusion:SfScheduler.AppointmentMapping>
                <syncfusion:AppointmentMapping
                    Subject="EventName"
                    StartTime="From"
                    EndTime="To"
                    AppointmentBackground="Color"
                    IsAllDay="IsAllDay"
                    StartTimeZone="StartTimeZone"
                    EndTimeZone="EndTimeZone"
                    RecurrenceExceptionDates="RecurrenceExceptions"
                    RecurrenceRule="RecurrenceRule"
                    RecurrenceId="RecurrenceId"
                    Reminders="Reminders">
                    <syncfusion:AppointmentMapping.ReminderMapping>
                        <syncfusion:ReminderMapping IsDismissed="Dismissed"
                                                    ReminderTimeInterval="TimeInterval"/>
                    </syncfusion:AppointmentMapping.ReminderMapping>
                </syncfusion:AppointmentMapping>
            </syncfusion:SfScheduler.AppointmentMapping>
        </syncfusion:SfScheduler>
public class ReminderViewModel 
{
  ...
  public ObservableCollection<Event> Events { get; set; } = new ObservableCollection<Event>();
  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

Scheduler notify 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: To avoid the reminder notify by enabling this property.
scheduler.ReminderAlertOpening += Scheduler_ReminderAlertOpening;

private void Scheduler_ReminderAlertOpening(object sender, ReminderAlertOpeningEventArgs e)
{
    var reminders = e.Reminders;
    var appointment = e.Reminders[0].Appointment;
}