wpf-devexpress-dot-xpf-dot-scheduling-dot-schedulercontrol-4bfd51db.md
Occurs when the user drags an object in the Scheduler from an external source.
Namespace : DevExpress.Xpf.Scheduling
Assembly : DevExpress.Xpf.Scheduling.v25.2.dll
NuGet Package : DevExpress.Wpf.Scheduling
public event StartAppointmentDragFromOutsideEventHandler StartAppointmentDragFromOutside
Public Event StartAppointmentDragFromOutside As StartAppointmentDragFromOutsideEventHandler
The StartAppointmentDragFromOutside event's data class is DevExpress.Xpf.Scheduling.StartAppointmentDragFromOutsideEventArgs.
The CompleteAppointmentDragDrop event does not fire if the drag-drop operation has been initialized outside the Scheduler.
The example below illustrates how to implement drag-drop from a text editor and GridControl.
private void Scheduler_StartAppointmentDragFromOutside(object sender,
StartAppointmentDragFromOutsideEventArgs e) {
// if the user is dragging GridControl data
if (e.Data.GetDataPresent(typeof(RecordDragDropData))) {
var rddData = (RecordDragDropData) e.Data.GetData(typeof(RecordDragDropData));
foreach (var appData in rddData.Records.Cast<AppointmentData>()) {
var appointment = new AppointmentItem {
Subject = appData.Subject,
Location = appData.Location
};
appointment.End = appointment.Start + appData.Length;
e.DragAppointments.Add(appointment);
}
}
// if the user is dragging text
if (e.Data.GetDataPresent(typeof(string))) {
var subject = (string) e.Data.GetData(typeof(string));
var appointment = new AppointmentItem { Subject = subject };
e.DragAppointments.Add(appointment);
}
}
Private Sub Scheduler_StartAppointmentDragFromOutside(ByVal sender As Object, ByVal e As StartAppointmentDragFromOutsideEventArgs)
' if the user is dragging GridControl data
If e.Data.GetDataPresent(GetType(RecordDragDropData)) Then
Dim rddData = CType(e.Data.GetData(GetType(RecordDragDropData)), RecordDragDropData)
For Each appData In rddData.Records.Cast(Of AppointmentData)()
Dim appointment = New AppointmentItem With {
.Subject = appData.Subject,
.Location = appData.Location
}
appointment.End = appointment.Start + appData.Length
e.DragAppointments.Add(appointment)
Next appData
End If
' if the user is dragging text
If e.Data.GetDataPresent(GetType(String)) Then
Dim subject = CStr(e.Data.GetData(GetType(String)))
Dim appointment = New AppointmentItem With {.Subject = subject}
e.DragAppointments.Add(appointment)
End If
End Sub
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the StartAppointmentDragFromOutside 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.
<dxsch:SchedulerControl x:Name="scheduler"
StartAppointmentDragFromOutside="scheduler_StartAppointmentDragFromOutside"
GroupType="Resource">
#line 19 "..\..\..\MainWindow.xaml"
this.scheduler.StartAppointmentDragFromOutside += new DevExpress.Xpf.Scheduling.StartAppointmentDragFromOutsideEventHandler(this.scheduler_StartAppointmentDragFromOutside);
#ExternalSource("..\..\MainWindow.xaml",19)
AddHandler Me.scheduler.StartAppointmentDragFromOutside, New DevExpress.Xpf.Scheduling.StartAppointmentDragFromOutsideEventHandler(AddressOf Me.scheduler_StartAppointmentDragFromOutside)
See Also