SchedulerControl.CustomAllowAppointmentConflicts Event
Occurs when a Scheduler appointment has been edited and allows you to define whether conflicts are present.
Namespace: DevExpress.Xpf.Scheduling
Assembly: DevExpress.Xpf.Scheduling.v25.1.dll
NuGet Package: DevExpress.Wpf.Scheduling
Declaration
Event Data
The CustomAllowAppointmentConflicts event's data class is AppointmentItemConflictEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Appointment | Gets the appointment for which the element is raised. Inherited from AppointmentItemEventArgs. |
AppointmentClone | Gets the clone of the appointment being processed. |
Conflicts | Gets the collection of appointments which are considered to be conflicting with the current appointment. |
Interval | Retrieves the time interval for which the event was raised. |
The event data class exposes the following methods:
Method | Description |
---|---|
RemoveConflictsWithDifferentResource(IList<AppointmentItem>, Object) | Removes all the conflicting appointments from the specified collection whose SchedulerItemBase.ResourceId doesn’t match the specified Id. |
Remarks
Handle the CustomAllowAppointmentConflicts
event to determine whether the current appointment conflicts with others. If not handled, the SchedulerControl.AllowAppointmentConflicts property controls whether appointment time intervals can overlap. When you handle this event, the SchedulerControl
will act like the SchedulerControl.AllowAppointmentConflicts property is set to false
.
Access the appointment’s copy using the AppointmentItemConflictEventArgs.AppointmentClone property.
Clear the AppointmentItemConflictEventArgs.Conflicts collection in this event handler if the current appointment has no conflicts. 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 an appointment if the user’s action should be canceled. You can also create a fake appointment and add it to the collection.
The source appointment (accessed using the AppointmentEventArgs.Appointment property) or its copy does not conflict if it is in the Conflicts collection. There should be other appointments in this collection to indicate the conflict.
Example
private void schedulerControl1_CustomAllowAppointmentConflicts(object sender, AppointmentItemConflictEventArgs e)
{
//Obtain the selected interval:
TimeInterval interval = e.Interval;
//If the appointment is to be moved to the restricted time interval,
//Add the dragged appointment the conflicting appointments collection:
if (!IsIntervalAllowed(interval))
e.Conflicts.Add(e.AppointmentClone);
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomAllowAppointmentConflicts event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.