Appointment Editing in WPF Scheduler (SfScheduler)

29 Jun 202210 minutes to read

This section explains how to handle appointment editing in WPF scheduler and also explains about the appointment resizing.

Adding appointments

Scheduler supports to add a new appointment by using the Appointment Editor UI window. Open this window by double-clicking on a time cell or month cell or view header.

NOTE

  • If AllowViewNavigation is true, the current view should be navigated to the respective day or timeline day views by single-clicking on the date in the view header. Other than the date by double-clicking on the view header cell, the appointment editor window will be opened, and by default, the AllDay checkbox will be checked in the appointment editor window.
  • All-day appointments can be created by double-clicking on the view header and not applicable for the month view header.

Editing appointment

Scheduler supports to edit the appointment by using Appointment Editor UI window. Open this window by double clicking on the appointment.

Appointment editor window

WPF Sfscheduler appointment editor window

Edit the appointments in appointment editor window. This changes will be saved back in appointment and mapped data object when using data binding.

Edit recurring appointment

Scheduler supports to edit the recurrence appointment. The following window will appear when the recurrence appointment is edited to select, whether to edit only the particular occurrence or appointment series.

WPF Scheduler editing recurrence appointment

Handle the opening of the recurrence popup window using the EditMode property in the RecurringAppointmentBeginningEditEventArgs by handling the RecurringAppointmentBeginningEdit event.

RecurringAppointmentBeginningEdit Event

The opening of the recurrence popup editor dialog can be handled using the EditMode property in the RecurringAppointmentBeginningEditEventArgs by handling the RecurringAppointmentBeginningEdit event.

EditMode: Gets or Sets the edit mode to perform the edit option to edit the occurrence or series for the recurrence appointment. The default value of the EditMode is User.

  • User: The default editor content dialog will appear when editing a recurrence appointment to select the edit option from the end-user itself.
  • Occurrence: Edit the particular occurrence alone in a recurrence appointment. The default editor content dialog will not appear.
  • Series: Edit the entire series in a recurrence appointment. The default editor content dialog will not appear.
this.scheduler.RecurringAppointmentBeginningEdit += scheduler_RecurringAppointmentBeginningEdit;

private void scheduler_RecurringAppointmentBeginningEdit(object sender, RecurringAppointmentBeginningEditEventArgs e)
{
	// Get or set the edit mode to perform the edit option.
	e.EditMode = RecurringAppointmentEditMode.Occurrence;
}

AppointmentEditorOpening event

When the appointment editor UI window is opened to add or update an appointment, then Scheduler notifies by the AppointmentEditorOpening event.

AppointmentEditorOpeningEventArgs has following members which provides the information for AppointmentEditorOpening event.

Appointment - Gets the selected appointment details which is being updated. It will be null when adding new appointment through appointment editor.

DateTime - Get the DateTime of time slot or month cell where user double clicked.

Cancel - To avoid the default appointment editor showing by enabling this property.

For example, to use a custom appointment editor window instead of the default appointment editor window, handle the AppointmentEditorOpening event.

this.Schedule.AppointmentEditorOpening += Schedule_AppointmentEditorOpening;

 private void Schedule_AppointmentEditorOpening(object sender, AppointmentEditorOpeningEventArgs e)
        {
            //To handle the default appointment editior window by setting the e.Cancel value as true.
            e.Cancel = true;
            if (e.Appointment != null)
            {
                //Display the custom appointment editor window to edit the appointment
            }
            else
            {
                //Display the custom appointment editor window to add new appointment
            }
        }
  • Resource - gets the resource of an appointment under which the appointment is located.

Visible/Collapse the built-in editors in appointment editor window

Programmatically visible or collapse the editors by setting the AppointmentEditorOptions property in SchedulerAppointmentEditorWindow. By default, the value of AppointmentEditorOptions is set to AppointmentEditorOptions.All in the SchedulerAppointmentEditorWindow that displays all the appointment editors. The following code shows how to collapse the Reminder and Resource editors by handling theAppointmentEditorOpening event.

this.Schedule.AppointmentEditorOpening += Schedule_AppointmentEditorOpening;

private void Schedule_AppointmentEditorOpening(object sender, AppointmentEditorOpeningEventArgs e)
{
    e.AppointmentEditorOptions = AppointmentEditorOptions.All | (~AppointmentEditorOptions.Background & ~AppointmentEditorOptions.Foreground & ~AppointmentEditorOptions.Reminder & ~AppointmentEditorOptions.Resource);
}

collapse-build-in-editors-of-appointment-editor-window-in-wpf-scheduler

NOTE

  • The basic editors such that Subject, Location, Start Hour and End Hour of the scheduler appointment editor will not be collapsed.

AppointmentEditorClosing event

When the appointment editor window is closed after adding or editing the schedule appointment, Scheduler notifies by AppointmentEditorClosing event.

AppointmentEditorClosingEventArgs has the following members which provides the information for AppointmentEditorClosing event.

Handled - Gets or sets a value that indicates whether the scheduler can update the underlying appointments collection or appointment based on the action performed in the appointment editor. If the value is true, scheduler does not perform the action so the code has to be written in the handler and perform the action. The default value of Handled is false.

Appointment - Gets the details of updated or newly added appointment.

Cancel - To avoid the default appointment editor closing by enabling this property.

Action - Gets the action of appointment which is Add, Edit, Delete or Cancel.

  • Add - Specifies that the appointment is newly added through appointment editor.
  • Edit - Specifies that the appointment is edited through appointment editor.
  • Delete - Specifies that the appointment is deleted through appointment editor.
  • Cancel - Specifies that the appointment editing is canceled through appointment editor.

For example, to handle the appointment adding for today’s date, user can handle the AppointmentEditorClosing event.

this.Schedule.AppointmentEditorClosing += Schedule_AppointmentEditorClosing;

private void Schedule_AppointmentEditorClosing(object sender, AppointmentEditorClosingEventArgs e)
        {
            var appointment = e.Appointment as ScheduleAppointment;
            if (appointment != null)
            {
                if (appointment.StartTime.Day == DateTime.Now.Day)
                    e.Handled = true;
            }
        }
  • Resource - gets the resource collection of edited appointment.

Disable appointment editing

To disable appointment editing functionality, Set AppointmentEditFlag property to None. In this case, add, edit, resize and drag & drop the appointments cannot be able performed.

<syncfusion:SfScheduler
            x:Name="Schedule"
           AppointmentEditFlag="None">
        </syncfusion:SfScheduler>

Delete appointments

Scheduler supports two ways to remove the selected appointment.

  1. Pressing delete key.
  2. Using appointment editor window.

Delete recurring appointment

Scheduler supports to delete the recurrence appointment. The following window will appear when the user deletes the recurrence appointment. Select the delete option to make the changes for occurrence or appointment series.

WPF Scheduler deleting recurrence appointment

AppointmentDeleting event

Scheduler notifies by AppointmentDeleting event, when user deletes the appointment.

AppointmentDeletingEventArgs has following members which provides information for AppointmentDeleting event.

Appointment - Gets the selected appointment to delete.

Cancel - To avoid appointment deleting by enabling this property.

Schedule.AppointmentDeleting += Schedule_AppointmentDeleting;

private void Schedule_AppointmentDeleting(object sender, AppointmentDeletingEventArgs e)
{
  //To notify when restrict appointment delete
  e.Cancel = true;
}

Appointment Resizing

Scheduler has support to resize the selected appointment. This support is available for all views except ‘Month’ view.

Disable appointment resize

Scheduler supports to disable the appointment resizing by setting AppointmentEditFlag property except Resize. In this case, appointment resizing cannot be performed.

<syncfusion:SfScheduler x:Name="Schedule"
                        AppointmentEditFlag="Add,DragDrop,Edit">
 </syncfusion:SfScheduler>
this.Schedule.AppointmentEditFlag = AppointmentEditFlag.Add | AppointmentEditFlag.DragDrop | AppointmentEditFlag.Edit;

AppointmentResizing event

Scheduler notifies by AppointmentResizing event when user resize an appointment.

AppointmentResizingEventArgs has following members which provides information for AppointmentResizing event.

Appointment - Gets the appointment being resized.

Action - Gets the current action being performed while resizing an appointment.

  • Starting - Denotes the event occurred when the user mouse over the appointment to resize an appointment (before showing resize cursor).
  • Progressing - Denotes the event occurred when the user resizing an appointment.
  • Committing - Denotes the event occurred when the user ends the resizing by releasing pointer to commit the changed to underlying appointment.
  • Canceling - Denotes the event occurred before canceling the resize operation, when the user press Esc key when resizing operation in progress.

StartTime - Gets the updated start time of the appointment in resizing operation.

EndTime - Gets the updated end time of the appointment in resizing operation.

CanContinueResize - Gets or sets a value indicating whether resizing the operation should be continued or canceled. Set this property when Action is Starting, Progressing, Canceling.This property won’t have any effect for when Action is Committing.

CanCommit - Gets or sets a value indicating whether to update underlying appointment when resizing operation is completed. Set this property when Action is Canceling and Committing. This property won’t have any effect for when Action is Starting and Progressing.

this.Schedule.AppointmentResizing += Schedule_AppointmentResizing;

 private void Schedule_AppointmentResizing(object sender, AppointmentResizingEventArgs e)
        {
            //To notify when resizing the appointment. 
        }
  • Resource - gets the resource of an appointment under which the appointment is located.

NOTE

You can also explore our WPF Scheduler example to knows how to schedule and manage appointments through an intuitive user interface, similar to the Outlook calendar.