How to: Set End-User Restrictions (legacy)
- 4 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 some real-life applications, it might be necessary to prevent end-users from creating or editing (copy, deleting, dragging, etc.) appointments shown within the SchedulerControl. For instance, it may be necessary to show all the appointments to end-users as read-only.
To implement end-user restrictions in your application, you can use the SchedulerControl.OptionsCustomization property providing access to the customization settings. The following restrictions are possible in the SchedulerControl:
|OptionsCustomization.AllowAppointmentConflicts||Gets or sets a value that specifies whether an end-user is allowed to share the schedule time between two or more appointments.|
|OptionsCustomization.AllowAppointmentCopy||Gets or sets a value that specifies whether an end-user is allowed to copy appointments.|
|OptionsCustomization.AllowAppointmentCreate||Gets or sets a value that specifies whether an end-user is allowed to create new appointments.|
|OptionsCustomization.AllowAppointmentDelete||Gets or sets a value that specifies whether an end-user is allowed to delete appointments.|
|OptionsCustomization.AllowAppointmentDrag||Gets or sets a value that specifies whether an end-user is allowed to drag and drop appointments to another time slot or date.|
|OptionsCustomization.AllowAppointmentDragBetweenResources||Gets or sets a value that specifies whether an end-user is allowed to drag and drop appointments between resources.|
|OptionsCustomization.AllowAppointmentEdit||Gets or sets a value that specifies whether an end-user is allowed to edit appointments.|
|OptionsCustomization.AllowAppointmentMultiSelect||Gets or sets a value that specifies whether an end-user is allowed to select more than one appointment simultaneously.|
|OptionsCustomization.AllowAppointmentResize||Gets or set a value that specifies whether an end-user is allowed to change the time boundaries of appointments.|
|OptionsCustomization.AllowDisplayAppointmentForm||Gets or sets the option specifying whether the Edit Appointment dialog can be invoked.|
|OptionsCustomization.AllowInplaceEditor||Gets or sets a value that specifies whether an inplace editor can be activated for an appointment.|
You can set a corresponding value as required, e.g. set UsedAppointmentType.None to prohibit a particular action for all appointment types, or set it to UsedAppointmentType.Recurring to allow it for recurring appointments only.
If you set one of the OptionsCustomization.Allow* properties to UsedAppointmentType.Custom, a related Allow* event will fire, in which you can decide how to handle a particular case.
This example demonstrates how to prevent end-users from having appointments within a certain time interval (from 2 PM to 3 PM). To implement end-user restrictions, handle the SchedulerControl.AllowAppointmentCreate event to prevent end-users from creating appointments within a certain time interval and the SchedulerControl.AllowAppointmentConflicts event to prevent an existing appointment from being dragged to the same time interval:
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-set-end-user-restrictions-e2516.
<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxsch="http://schemas.devexpress.com/winfx/2008/xaml/scheduler" Title="MainWindow" Height="350" Width="525"> <Grid> <dxsch:SchedulerControl Name="schedulerControl1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" AllowAppointmentConflicts="schedulerControl1_AllowAppointmentConflicts" AllowAppointmentCreate="schedulerControl1_AllowAppointmentCreate"> <dxsch:SchedulerControl.DayView> <dxsch:DayView DayCount="3" /> </dxsch:SchedulerControl.DayView> <dxsch:SchedulerControl.OptionsCustomization> <dxsch:OptionsCustomization AllowAppointmentConflicts="Custom" AllowAppointmentCreate="Custom" /> </dxsch:SchedulerControl.OptionsCustomization> </dxsch:SchedulerControl> </Grid> </Window>