Occurs when the scheduler finds appointments that are in conflict, and the OptionsCustomization.AllowAppointmentConflicts property is set to Custom.
public event AppointmentConflictEventHandler AllowAppointmentConflicts
Public Event AllowAppointmentConflicts As AppointmentConflictEventHandler
The AllowAppointmentConflicts event's data class is AppointmentConflictEventArgs. The following properties provide information specific to this event:
|Appointment||Gets the appointment for which the event was raised. Inherited from AppointmentEventArgs.|
|AppointmentClone||Gets the clone of the appointment being processed in the SchedulerControl.AllowAppointmentConflicts or the SchedulerControl.AllowAppointmentConflicts events.|
|Conflicts||Gets the collection of appointments which are considered to be conflicting with the current appointment.|
|Interval||Gets the time interval which the event was raised for.|
The event data class exposes the following methods:
|RemoveConflictsWithDifferentResource(AppointmentBaseCollection, Object)||Removes all the conflicting appointments from the specified collection whose Appointment.ResourceId doesn’t match the specified Id.|
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.
Handle the AllowAppointmentConflicts event to manually decide whether the current appointment conflicts with any other appointments. The appointment’s copy to be checked can be accessed via the AppointmentEventArgs.Appointment property.
This event’s arguments provide the AppointmentConflictEventArgs.Conflicts property, which returns the collection of appointments that are considered to be conflicting by the SchedulerControl. All these appointments conflict with the current appointment, since their time intervals intersect and they are assigned the same resource. If the Conflicts collection is empty, this means that there are no conflicting appointments.
The AppointmentConflictEventArgs.AppointmentClone property contains an appointment modified due to an end-user’s action. This is the appointment that intersects with existing ones. The Appointment property provides access to the current appointment before modification. So, when an appointment is dragged, its clone may conflict with original appointment, and the Conflicts collection may contain one element - the original appointment.
If you determine that the current appointment has no conflicts, you should clear the Conflicts collection in this event’s handler. If you determine that the current appointment has at least one conflict, then the Conflicts collection should contain at least one object that is different from the current appointment. The non-empty Conflicts collection cancels the user’s action that caused a conflict. The common practice is to clear the Conflicts collection at the beginning, and populate it with any appointment if the user’s action should be canceled. You can even create a fake appointment for this purpose and add it to the collection.
The source appointment (accessed via the AppointmentEventArgs.Appointment property) or its copy isn’t considered to be conflicting if it’s present in the Conflicts collection. There should be other appointments in this collection, to indicate the conflict.
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>