Back to Devexpress

SchedulerControl.DropAppointment Event

wpf-devexpress-dot-xpf-dot-scheduling-dot-schedulercontrol-00bb31b4.md

latest7.2 KB
Original Source

SchedulerControl.DropAppointment Event

Occurs when the user drops appointments within a Scheduler’s view.

Namespace : DevExpress.Xpf.Scheduling

Assembly : DevExpress.Xpf.Scheduling.v25.2.dll

NuGet Package : DevExpress.Wpf.Scheduling

Declaration

csharp
public event DropAppointmentEventHandler DropAppointment
vb
Public Event DropAppointment As DropAppointmentEventHandler

Event Data

The DropAppointment event's data class is DropAppointmentEventArgs. The following properties provide information specific to this event:

PropertyDescription
AllowedEffectsReturns a member of the DragDropEffects enumeration that specifies which operations are allowed by the originator of the drag event.
CancelGets or sets whether the event should be canceled. Inherited from CancelRoutedEventArgs.
ConflictedAppointmentsReturns the collection of dragged appointments that are conflicting with the current appointments.
DataAllows you to generate an appointment when the user drags an object in the Scheduler from an external source.
DragAppointmentsReturns the list of dragged appointments.
EffectsReturns a member of the DragDropEffects enumeration that specifies which operation is the result of the drag-drop operation.
HandledGets or sets a value that indicates the present state of the event handling for a routed event as it travels the route. Inherited from RoutedEventArgs.
IsFromOutsideIndicates whether the content was dragged from an external control or application.
KeyStatesGets a flag enumeration indicating the current state of the SHIFT, CTRL, and ALT keys, as well as the state of the mouse buttons.
OriginalSourceGets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class. Inherited from RoutedEventArgs.
RoutedEventGets or sets the RoutedEvent associated with this RoutedEventArgs instance. Inherited from RoutedEventArgs.
SourceGets or sets a reference to the object that raised the event. Inherited from RoutedEventArgs.
SourceAppointmentsProvides access to the collection of dragged appointments before the drag-drop operation.

The event data class exposes the following methods:

MethodDescription
InvokeEventHandler(Delegate, Object)When overridden in a derived class, provides a way to invoke event handlers in a type-specific way, which can increase efficiency over the base implementation. Inherited from RoutedEventArgs.
OnSetSource(Object)When overridden in a derived class, provides a notification callback entry point whenever the value of the Source property of an instance changes. Inherited from RoutedEventArgs.

Remarks

Set the event’s Cancel property to true to disable the default Scheduler’s drop behavior.

The example below illustrates how to override the AllowAppointmentConflicts property that is set to false.

csharp
private void Scheduler_DropAppointment(object sender, DropAppointmentEventArgs e) {
    for (int i = 0; i < e.DragAppointments.Count; i++) {
        //if a dragged appointment does not intersect another appointment
        if (e.ConflictedAppointments[i].Count == 0) {
            //it can be moved to the desired position
            e.SourceAppointments[i].Start = e.DragAppointments[i].Start;
            e.SourceAppointments[i].End = e.DragAppointments[i].End;
    }
}
vb
Private Sub Scheduler_DropAppointment(ByVal sender As Object, ByVal e As DropAppointmentEventArgs)
    For i As Integer = 0 To e.DragAppointments.Count - 1
        'if a dragged appointment does not intersect another appointment
        If e.ConflictedAppointments(i).Count = 0 Then
            'it can be moved to the desired position
            e.SourceAppointments(i).Start = e.DragAppointments(i).Start
            e.SourceAppointments(i).End = e.DragAppointments(i).End
        End If
    Next i

See Also

SchedulerControl Class

SchedulerControl Members

DevExpress.Xpf.Scheduling Namespace