Reminder in WPF Scheduler (SfScheduler)

4 Jan 2021 / 9 minutes to read

Scheduler alerts you for a particular appointment with a reminder window when enabling the EnableReminder property. Reminder window supports to Dismiss or DismissAll or set the SnoozeTime for the reminder appointments.

Enable reminder

Reminder can be set by setting the EnableReminder property is true. The reminder time can be set using the Reminders property of ScheduleAppointment.

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

WPF Scheduler reminder alert window

Adding reminders

You can configure the appointment reminders with SchedulerReminder. The SchedulerReminder has the following properties for reminder alert,

Properties Description

ReminderTimeInterval

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

ReminderAlertTime

Gets the reminder time that decides when to show a reminder alert 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)ColorConverter.ConvertFromString("#FF339933")),
        Subject = "Conference",
        Reminders = new ObservableCollection<SchedulerReminder>
        {
            new SchedulerReminder { ReminderTimeInterval = new TimeSpan(0)},
        }
    });
 }

NOTE

View sample in GitHub

Creating business object for reminder

Reminders supports to map your 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 for reminder alert,

  • ReminderTimeInterval - Maps the property name of custom class, which is equivalent for the SchedulerReminder.ReminderTimeInterval.
  • IsDismissed - Maps the property name of custom class, which is equivalent for the SchedulerReminder.IsDismissed.
/// <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 the value to display reminder alert before appointment start time.
    /// </summary>
    public TimeSpan TimeInterval { get; set; }

}

You can map those properties of the Meeting class with the SfScheduler control by using the AppointmentMapping and map CustomReminder properties with 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)},
    }
    });
}

NOTE

View sample in GitHub

ReminderAlertOpening event

Scheduler notifies by the ReminderAlertOpening event when appearing in the reminder window. The ReminderAlertOpeningEventArgs has following properties,

  • Reminders - Gets a list of reminders that are used to display the appointment reminders in the reminder alert window.
  • Cancel - To avoid the reminder window opening 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;
}