This is a migrated thread and some comments may be shown as answers.

Multiple Target DragAndDrop

3 Answers 117 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Andrei
Top achievements
Rank 1
Iron
Andrei asked on 05 Nov 2014, 02:29 PM
Hi.

I have a drag drop setup between a RadListBoxA (type A objects) and  a ScheduleView(Appointments)

I use OnDragInitialize on the ListBox like this:
private void OnDragInitialize(object sender, DragInitializeEventArgs args)
        {
            var leg = ((sender as ContentControl).Content as TransportOrderLegViewModel);
 
            
            // Convert Data to ScheduleView Payload
            var appt = new Appointment() {  };
            if (leg.Planned)
            {
                appt.Location = "Test";
            }
 
            var payload = new ScheduleViewDragDropPayload(null, new List<IOccurrence>() { appt });
 
            args.Data = payload;
 
 
            // Create DragVisual
            var cc = new ContentControl();
            cc.ContentTemplate = Resources.MergedDictionaries[2]["TOLDragVisualTemplate"] as DataTemplate;
            cc.Content = leg;
            args.DragVisual = cc;
            args.AllowedEffects = DragDropEffects.All;
 
            args.DragVisualOffset = args.RelativeStartPoint;
            args.Handled = true;
        }
In the schedule view I use ScheduleViewLevel1DragDropBehavior : ScheduleViewDragDropBehavior.
In the public override bool CanDrop(DragDropState state) the state.DraggedAppointments shows the appointments , so it all works. 

I will point out here that DragDropState is in fact for this converter an Telerik.Windows.Controls.DragDropState.

THE PROBLEM

Now I have to enable that the objects from RadListBoxA( Type A ) can also be dropped in another RadListBoxB (type B)

RadListBoxB already has dragging enabled from other sources , so it uses a SchematicViewListBoxDragDropBehavior : ListBoxDragDropBehavior
What I noticed is that in the override of CanDrop(DragDropState state) , DragDropState type comes from another namespace: Telerik.Windows.DragDrop.Behaviors.DragDropState

Whenever I drag something from RadListBoxA to RadListBoxB the state.DraggedItems has no elements. 

I thought of using the payload.SetData on the ScheduleViewDragDropPayload to attach extra data , but it doesn't implement that , as it seems it's a different kind of payload than the ones used in other documentation , for example this:
var payload = DragDropPayloadManager.GeneratePayload(null);
var data = ((FrameworkElement)args.OriginalSource).DataContext;
payload.SetData("DragData", data);
args.Data = payload;


Any suggestions would be much welcome. I'm hoping there is a way of doing it without having to rewrite the whole DragAndDrop between all the other controls that are already working nicely.

Thank you

3 Answers, 1 is accepted

Sort by
0
Accepted
Nasko
Telerik team
answered on 07 Nov 2014, 04:24 PM
Hi Andrei,

Thank you for contacting us.

Based on the provided description we assume that the issue occurs because the type of the items dragged from the first ListBox control does not match the type of the items of  the second ListBox. In order to resolve it you need to create a custom DataConverter for the second ListBox as demonstrated in this article form our help documentation:
http://www.telerik.com/help/wpf/radlistbox-features-dragdrop-scheduleview.html

You can also check that sample project in our SDK Repository that demonstrates the described in the article approach.

Please give it a try and let us know if it worked for you.

Regards,
Nasko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Andrei
Top achievements
Rank 1
Iron
answered on 09 Dec 2014, 11:35 AM
Thanks , It worked in the end.
0
Andrei
Top achievements
Rank 1
Iron
answered on 09 Dec 2014, 11:35 AM
thanks
Tags
DragAndDrop
Asked by
Andrei
Top achievements
Rank 1
Iron
Answers by
Nasko
Telerik team
Andrei
Top achievements
Rank 1
Iron
Share this question
or