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

Using DragDropManager events and RadTreeView, how do I determine the dropposition (after,before,inside)?

6 Answers 96 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Anders
Top achievements
Rank 1
Anders asked on 18 Jun 2013, 09:19 PM
I am dragging within a single treeview

Thanks,
Anders, Denmark

6 Answers, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 21 Jun 2013, 10:59 AM
Hello,

You can subscribe to the DragOver event of the RadTreeView and check the TreeViewDragDropOptions.DropPosition property. For more details please refer to this article.

Feel free to ask if you have any other questions.

Regards,
Pavel R. Pavlov
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Anders
Top achievements
Rank 1
answered on 24 Jun 2013, 06:48 AM
Hi Pavlov,

Thanks (and I had seen the example before asking), but using the code and checking just for null, the options is always null. What should I do to get options extracted form event data? Do you have a coherent example?
0
Anders
Top achievements
Rank 1
answered on 24 Jun 2013, 07:51 AM
Maybe I should elaborate a bit ;)

Checking the non-public contents of the args.Data, I can see that innerData appear to be a dictionary containing a single item -- the dragged item under a key "DragData" -- which I guess is what I supplied myself under the event DragInitialize (done to be in accordance with one of your other examples...).

        public void OnDragInitialize(object sender, DragInitializeEventArgs args)
        {
                //DragInitialize - The DragInitialize event occurs when an object is about to be dragged.
                // All needed information about the drag should be passed to the event arguments.
                // Drag start can be stopped by setting Cancel=true. This is a bubbling event.

            
var payload = DragDropPayloadManager.GeneratePayload(null);
            payload.SetData("DragData", ((FrameworkElement) args.OriginalSource).DataContext);
            args.Data = payload;
        }
 
public void OnDragOver(object sender, DragEventArgs args)
        {
            //DragOver - This event occurs continuously while an object is dragged (moved) within the drop target's boundary.
            // This is a bubbling event.
 
            var dataFromObject = DragDropPayloadManager.GetDataFromObject(args.Data, TreeViewDragDropOptions.Key);
            Debug.WriteLine("Always null: " + dataFromObject);
             
            var options = dataFromObject as TreeViewDragDropOptions;
            if (options != null )
            {
                Debug.WriteLine("This never happends");
                var relativePosition = GetRelativePosition(options.DropPosition);
                _dragStateManager.SetDropPosition(relativePosition);
                options.UpdateDragVisual();
            }           
            args.Handled = true;
        }
0
Accepted
Pavel R. Pavlov
Telerik team
answered on 26 Jun 2013, 12:18 PM
Hello Anders,

I tried to reproduce the behavior that you report on our side by creating a sample application and it look like the code is working as expected. Can you please take a look at it and see if I missed something. It will be great if you can change the code so that your issue can be reproduced on our side and send the project back. By doing so we will be able to further investigate the reasons behind this behavior.

Thank you for your cooperation.

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Anders
Top achievements
Rank 1
answered on 26 Jun 2013, 02:27 PM
There -- reproduced. And I found the culprit in OnDragInitialize. I set the payload using an example from your site.

My bad of course -- but still it would have been helpful with updated DragDropManager examples going just slightly off the beaten track. Specifically, we update the model behind the treeview and therefore need information about what is going on, whereas all(?) examples just update the treeview datamodel and do it well...

NOTE: I am not allowed to attach zip file ...

Anders, Denmark
0
Pavel R. Pavlov
Telerik team
answered on 01 Jul 2013, 10:37 AM
Hello Anders,

As our client, you can log into your Telerik account and submit a question using our ticketing system. In the ticket you will be allowed to attach zip files. Please submit a ticket with your question and attach your project in it. By doing so, we will be able to reproduce the behavior that you report on our side and further investigate your certain scenario in order to make further suggestion.

Thank you for understanding.

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
TreeView
Asked by
Anders
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Anders
Top achievements
Rank 1
Share this question
or