Note
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 document describes how to create a custom appointment recurrence editing form using recurrence controls provided by DXScheduler for the WPF Suite and use this form instead of the default one. The default Edit Appointment form is remained unchanged in this example.
- Open the scheduling WPF application created in Lesson 2 of the Getting Started tutorial.
Create a custom appointment recurrence editing form that allows end-users to set an appointment recurrence range. To do this, add a new User Control (under the CustomRecurrenceForm.xaml name) to the WpfApplication1 project. Locate the RecurrenceRangeControl and two Button (OK and Cancel) controls on this form.
<UserControl x:Class="WpfApplication1.CustomRecurrenceForm"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dxsch="http://schemas.devexpress.com/winfx/2008/xaml/scheduler"
xmlns:dxschint="http://schemas.devexpress.com/winfx/2008/xaml/scheduler/internal"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
Loaded="UserControl_Loaded">
<Grid Margin="12">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<dxsch:RecurrenceRangeControl
RecurrenceInfo="{Binding RecurrenceVisualController.RecurrenceInfo}"
Pattern="{Binding RecurrenceVisualController.Controller.PatternCopy}"
TimeZoneHelper="{Binding TimeZoneHelper, Mode=OneTime}"
IsEnabled="{Binding ReadOnly, Converter={dxschint:InvertedBoolConverter}}"/>
<StackPanel Grid.Row="1"
Orientation="Horizontal" HorizontalAlignment="Right"
Margin="0,8,0,0">
<Button x:Name="OK" Content="OK"
MinWidth="75" Margin="6,0,0,0" Click="OK_Click"/>
<Button x:Name="Cancel" Content="Cancel"
MinWidth="75" Margin="6,0,0,0" Click="Cancel_Click"/>
</StackPanel>
</Grid>
</UserControl>
using System.Windows;
using System.Windows.Controls;
using DevExpress.XtraScheduler;
using DevExpress.Xpf.Scheduler;
using DevExpress.Xpf.Scheduler.UI;
namespace WpfApplication1 {
public partial class CustomRecurrenceForm : UserControl {
public CustomRecurrenceForm(AppointmentFormController controller) {
RecurrenceVisualController = new StandaloneRecurrenceVisualController(controller);
Controller = controller;
InitializeComponent();
}
public AppointmentFormController Controller { get; private set; }
public StandaloneRecurrenceVisualController RecurrenceVisualController { get; private set; }
public TimeZoneHelper TimeZoneHelper { get { return RecurrenceVisualController.Controller.TimeZoneHelper; } }
private void UserControl_Loaded(object sender, RoutedEventArgs e) {
SchedulerFormBehavior.SetTitle(this, "Recurrence Range");
}
private void OK_Click(object sender, RoutedEventArgs e) {
RecurrenceVisualController.ApplyRecurrence();
CloseForm(true);
}
private void Cancel_Click(object sender, RoutedEventArgs e) {
CloseForm(false);
}
void CloseForm(bool dialogResult) {
SchedulerFormBehavior.Close(this, dialogResult);
}
}
}
Imports Microsoft.VisualBasic
Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports DevExpress.XtraScheduler
Imports DevExpress.Xpf.Scheduler
Imports DevExpress.Xpf.Scheduler.UI
Public Class CustomRecurrenceForm
Public Sub New(ByVal controller As AppointmentFormController)
RecurrenceVisualController = New StandaloneRecurrenceVisualController(controller)
controller = controller
InitializeComponent()
End Sub
Private privateController As AppointmentFormController
Public Property Controller() As AppointmentFormController
Get
Return privateController
End Get
Private Set(ByVal value As AppointmentFormController)
privateController = value
End Set
End Property
Private privateRecurrenceVisualController As StandaloneRecurrenceVisualController
Public Property RecurrenceVisualController() As StandaloneRecurrenceVisualController
Get
Return privateRecurrenceVisualController
End Get
Private Set(ByVal value As StandaloneRecurrenceVisualController)
privateRecurrenceVisualController = value
End Set
End Property
Public ReadOnly Property TimeZoneHelper() As TimeZoneHelper
Get
Return RecurrenceVisualController.Controller.TimeZoneHelper
End Get
End Property
Private Sub UserControl_Loaded(sender As Object, e As RoutedEventArgs)
SchedulerFormBehavior.SetTitle(Me, "Recurrence Range")
End Sub
Private Sub OK_Click(sender As Object, e As RoutedEventArgs)
RecurrenceVisualController.ApplyRecurrence()
CloseForm(True)
End Sub
Private Sub Cancel_Click(sender As Object, e As RoutedEventArgs)
CloseForm(False)
End Sub
Private Sub CloseForm(ByVal dialogResult As Boolean)
SchedulerFormBehavior.Close(Me, dialogResult)
End Sub
End Class
To replace the standard Appointment Recurrence form with a newly created custom one, handle the SchedulerControl.RecurrenceFormShowing event. Set the FormShowingEventArgs.Form property to the CustomRecurrenceForm class instance with the passed AppointmentFormController controller of the Edit Appointment form that is accessed via RecurrenceFormEventArgs.ParentForm.
<dxsch:SchedulerControl Name="schedulerControl1"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
ActiveViewType="Week"
GroupType="Resource"
RecurrenceFormShowing="schedulerControl1_RecurrenceFormShowing">
private void schedulerControl1_RecurrenceFormShowing(object sender, RecurrenceFormEventArgs e) {
AppointmentForm appointmentForm = e.ParentForm as AppointmentForm;
e.Form = new CustomRecurrenceForm(appointmentForm.Controller);
}
Private Sub schedulerControl1_RecurrenceFormShowing(sender As Object, _
e As RecurrenceFormEventArgs)
Dim appointmentForm As AppointmentForm = TryCast(e.ParentForm, AppointmentForm)
e.Form = New CustomRecurrenceForm(appointmentForm.Controller)
End Sub
Run the project. The custom appointment recurrence editing form will be invoked when selecting New Recurring Appointment or New Recurring Event from the context menu, selecting Edit Series from the recurring appointment context menu or clicking the Recurrence button on the default appointment editing form.
See Also