Drag from ListView to Schedule - how to get the details of the appointment which is dragged to update database

Hi,

I would be grateful for your advice please. I have a scheduler object in a WPF window with a listview which has SchedulerModel objects as contents (as per the example DragAndDrop). I can drag and drop these into the Schedule control and they are added to the Appointment list which is it bound to. This is all hooked up to a backend SQL Server DB and is working well.

I am, however, struggling to get the details for the dropped appointment which has references to data in addition to the standard ScheduleAppointment information. I have tried all of the permutations I can think of but am struggling tio get the details I need to create a new appointment record in the background database. I can get the droptime from the Scheduler but not the item which was dropped.

I'm conscious I am trying to do this through the code behind for the window (this.schedule.AppointmentDropping) where the rest of the window is built using the MVVM pattern.

It would be ok if I could open a new appointment editor window with the details for the dropped appointment completed and ask them to Save it to create the database entry if that is an easier solution (the appointment editor is already linked to the database). Any advice as to how to achieve this would be gratefully received.

Many thanks.




1 Reply

KA Karthikraja Arumugam Syncfusion Team June 22, 2021 03:56 PM UTC

Hi Lynne, 
 
Greetings from Syncfusion. 
 
We have checked your requirement based on the shared details we suspect that you can achieve your requirement in Scheduler.Drop event itself, after adding dropped appointment to scheduler appointment collection update it to your DB collection.  
 
scheduler.Drop += OnSchedulerDrop;               
 
private void OnSchedulerDrop(object sender, DragEventArgs e) 
 { 
            var appointment = e.Data.GetData("draggingAppointment") as SchedulerModel; 
             
            …. 
            …. 
 
            if (!dragDropViewModel.SchedulerAppointmentCollection.Contains(appointment)) 
            { 
                dragDropViewModel.SchedulerAppointmentCollection.Add(appointment); 
                // Configure DB update here 
            } 
  } 
 
Appointment editor opening is configured only on tap interaction so we can’t open editor on dropping appointment into scheduler. Please check the above solution and if this doesn’t meet your requirement kindly modify our Drag and Drop sample with listview with more details. 
 
Sample link: DragAndDropSample 
 
Regards, 
Karthik Raja A 


Loader.
Up arrow icon