How to: Invoke the Default Appointment Recurrence Dialog from a Custom Edit Appointment Form (legacy
- 3 minutes to read
You are viewing documentation for the legacy WPF Scheduler control. If you're starting a new project, we strongly recommend that you use a new control declared in the DevExpress.Xpf.Scheduling namespace. If you decide to upgrade an existing project in order to switch to the updated scheduler control, see the Migration Guidelines document.
This example demonstrates how to provide end-users with the capability to work with recurring appointments via the standard Appointment Recurrence dialog that should be invoked from a custom Edit Appointment form.
- Open the scheduling WPF application created in Lesson 9 of the Getting Started tutorial. This application contains the scheduler control that is already bound to the required data source. The standard Edit Appointment form is replaced with a custom one. The Appointment Recurrence feature is disabled and custom appointment editing dialog does not allow end-users to invoke the Appointment Recurrence dialog for creating and editing recurring appointments.
Enable the Appointment Recurrence feature by specifying mappings for the Appointment.RecurrenceInfo and Appointment.Type standard properties of an appointment. To do this, use the AppointmentMapping.RecurrenceInfo and AppointmentMapping.Type properties.
<dxsch:SchedulerStorage.AppointmentStorage> <dxsch:AppointmentStorage> <dxsch:AppointmentStorage.Mappings> <dxsch:AppointmentMapping Start="StartTime" End="EndTime" AllDay="AllDay" Description="Description" Label="Label" Location="Location" Subject="Subject" ReminderInfo="ReminderInfo" ResourceId="CarId" Status="Status" RecurrenceInfo="RecurrenceInfo" Type="EventType"/> </dxsch:AppointmentStorage.Mappings> <!--...--> </dxsch:AppointmentStorage> </dxsch:SchedulerStorage.AppointmentStorage>
Now, recurring appointments contained in the data source are displayed in the scheduler control according to recurrence information specified by patterns. The default context menu includes the New Recurring Appointment and New Recurring Event items, and the recurring appointment context menu includes the Edit Series item, but the Appointment Recurrence dialog is still unavailable for end-users and recurrence patterns cannot still be created and edited.
To use the standard appointment recurrence editing form for creating recurring appointments, handle the SchedulerControl.RecurrenceFormShowing event and set the RecurrenceFormEventArgs.Controller property to the appointment editing form's controller. To access an instance of the class specifying the appointment editing form, use RecurrenceFormEventArgs.ParentForm.
<dxsch:SchedulerControl Name="schedulerControl1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ActiveViewType="Week" GroupType="Resource" EditAppointmentFormShowing="schedulerControl1_EditAppointmentFormShowing" RecurrenceFormShowing="schedulerControl1_RecurrenceFormShowing">
Now, the default Appointment Recurrence form is invoked when an end-user creates a new recurring appointment by selecting New Recurring Appointment or New Recurring Event from the context menu. However, it is still impossible to modify recurrence patterns of existing appointments.
Provide the capability to invoke the standard Appointment Recurrence dialog from the custom Edit Appointment form. To do this, add the Recurrence button to your custom appointment editing form and call the SchedulerControl.ShowRecurrenceForm method in this button's Click event handler. To specify the Recurrence button visibility, use the AppointmentFormController.ShouldShowRecurrence property.
Run the project. End-users are provided with the comprehensive functionality for working with appointments of different types (simple and recurring) via the custom Edit Appointment form to specify main and custom appointment properties (Subject, Start, End, Label, Status, etc.) and via the default Appointment Recurrence form to create and modify recurrence patterns.
A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E3796.