Skip to main content

Lesson 8 - Create a Custom Appointment Recurrence Dialog Using the MVVM Pattern (legacy)

  • 5 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.

In this lesson, you will learn how to use the MVVM design pattern to customize the default Appointment Recurrence dialog, which can be invoked by clicking the Recurrence button in the Edit Appointment form.


Before starting the example, you must perform the steps described in Lesson 7 - Create a Custom Edit Appointment Form Using the MVVM Pattern (legacy) of the current tutorial. This lesson demonstrates how to create the scheduling application and customize the default appointment editing form by utilizing an MVVM-based mechanism for form display.

The tutorial includes the following sections.

Enable the Recurrence Functionality

  1. Open the WPF application with the SchedulerControl, which was created in Lesson 7 - Create a Custom Edit Appointment Form Using the MVVM Pattern (legacy) of the current tutorial.
  2. Open the MainViewModel file and implement the Recurrence and Type properties of the HospitalAppointment class. The values of these properties will be used to save and load the recurrence information in the data source (in this example, the System.ComponentModel.BindingList<HospitalAppointment> collection is used to define the data source).

    public class HospitalAppointment
         // ...
         public string Recurrence { get; set; }
         public int Type { get; set; }
  3. Switch to the MainWindow.xaml file. Use the AppointmentStorage.Mappings property to bind an appointment’s Appointment.RecurrenceInfo and Appointment.Type properties to the Recurrence and Type fields of the data source.

         <dxsch:AppointmentMapping Start="StartTime" 

Add the Recurrence Button to the Edit Appointment Form

Open the HospitalAppointmentForm.xaml file. Add the Recurrence button to the form next to the Cancel button. Bind the button to EditRecurrenceCommand to enable creating and editing recurring appointments using the Appointment Recurrence dialog.


<StackPanel Grid.Row="8" Grid.Column="1" Grid.ColumnSpan="2" 
            Orientation="Horizontal" HorizontalAlignment="Right">
     <!--OK button-->
     <!--Cancel button-->
     <!--Recurrence button-->
     <Button x:Name="btnRecurrence"
           Command="{Binding EditRecurrenceCommand}" MinWidth="75" Margin="6,0,0,0"/>

Create a Custom Appointment Recurrence Dialog

  1. In the Solution Explorer, right-click the project’s name (MVVMSchedulerApplication) and select Add | User Control…


  2. In the Add New Item dialog, select the WPF group of templates, click the User Control (WPF) item, change its name to HospitalRecurrenceForm.xaml, and then click Add.


  3. Locate the RecurrenceTypeEditor, DailyRecurrenceControl, WeeklyRecurrenceControl, MonthlyRecurrenceControl and RecurrenceRangeControl controls on the Recurrence form. To enable editing the recurrence pattern of an appointment, bind the added controls to the corresponding property values of the DevExpress.Xpf.Scheduler.UI.RecurrenceDialogViewModel object, which serves as a data context for any bindings within the form.


    As a result, your XAML may look like the following. (If it does not, you can overwrite your code with the code below).

    <UserControl x:Class="MVVMSchedulerApplication.HospitalRecurrenceForm"
         <dx:BoolToVisibilityConverter x:Key="booleanToVisibilityConverter" />
     <Grid Margin="12" Background="Snow">
                <RowDefinition Height="*" />
                <RowDefinition Height="*" />
         <!--Recurrence Pattern Group-->
         <dx:GroupFrame Header="Recurrence Pattern" Margin="0,12,0,0" Background="Red">
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    <dxschdui:RecurrenceTypeEditor RecurrenceType="{Binding RecurrenceType, Mode=TwoWay}" RecurrenceTypes="{Binding AvailableRecurrenceTypes}" IsReadOnly="{Binding IsReadOnly}" />
                    <StackPanel Grid.Column="2" Margin="15,0,0,0">
                        <dxsch:DailyRecurrenceControl Visibility="{Binding IsDailyRecurrence, Converter={dxschi:BoolToVisibilityConverter}}" 
                                                      RecurrenceInfo="{Binding RecurrenceInfo}" IsReadOnly="{Binding IsReadOnly}" />
                        <dxsch:WeeklyRecurrenceControl Visibility="{Binding IsWeeklyRecurrence, Converter={dxschi:BoolToVisibilityConverter}}" 
                                                      RecurrenceInfo="{Binding RecurrenceInfo}" IsReadOnly="{Binding IsReadOnly}" FirstDayOfWeek="{Binding FirstDayOfWeek}" />
                        <dxsch:MonthlyRecurrenceControl Visibility="{Binding IsMonthlyRecurrence, Converter={dxschi:BoolToVisibilityConverter}}" 
                                                      RecurrenceInfo="{Binding RecurrenceInfo}" IsReadOnly="{Binding IsReadOnly}" />
         <!--Recurrence End Group-->
         <dx:GroupFrame Grid.Row="1" Header="Recurrence End" Margin="0,12,0,0">
                <dxsch:RecurrenceRangeControl RecurrenceInfo="{Binding RecurrenceInfo}"
                            TimeZoneHelper="{Binding TimeZoneHelper, Mode=OneTime}"
                            Pattern="{Binding PatternCopy}" IsReadOnly="{Binding IsReadOnly}"/>

Use a Data Template to Display the Custom Dialog

Switch to the MainWindow.xaml file. To invoke the created Appointment Recurrence form, you need to specify a data template that contains a service used to display the form’s View. By default, the DialogService is used as a service to show the dialog window. Utilize the SchedulerControl.AppointmentRecurrenceDialogServiceTemplate property to specify the data template. To display your custom form instead of the standard one, set the ViewServiceBase.ViewTemplate property to HospitalRecurrenceForm. To define the style and size of the dialog, utilize the DialogService.DialogStyle property. The XAML code implementing this approach is shown below.

         <dx:DialogService DialogWindowStartupLocation="CenterOwner">
                 <Style TargetType="dx:DXWindow">
                     <Setter Property="SizeToContent" Value="WidthAndHeight"/>


Run the project. Double-click any appointment or create a new one to invoke the Edit Appointment form. In the form, click the Recurrence button to display the custom Appointment Recurrence dialog shown in the image below.


See Also