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

7 posts, 1 answers
  1. Anders
    Anders avatar
    80 posts
    Member since:
    Dec 2010

    Posted 18 Jun 2013 Link to this post

    I am dragging within a single treeview

    Thanks,
    Anders, Denmark
  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 21 Jun 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Anders
    Anders avatar
    80 posts
    Member since:
    Dec 2010

    Posted 24 Jun 2013 Link to this post

    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?
  5. Anders
    Anders avatar
    80 posts
    Member since:
    Dec 2010

    Posted 24 Jun 2013 Link to this post

    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;
            }
  6. Answer
    Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 26 Jun 2013 Link to this post

    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 >>
  7. Anders
    Anders avatar
    80 posts
    Member since:
    Dec 2010

    Posted 26 Jun 2013 Link to this post

    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
  8. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 01 Jul 2013 Link to this post

    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 >>
Back to Top
UI for WPF is Visual Studio 2017 Ready