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

Disable drop before and drop after

6 Answers 158 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 28 Apr 2011, 03:44 PM
Hi,

I'm currently using a RadTreeView with drag and drop function enabled. I implemented the dragended event with business logic for saving the changed stucture of the tree into the database. But I don't want to use the dropbefore and dropafter, how can I disable these actions.

I've read previous post about disabling the drop before and drop after which was created in 2009.
http://www.telerik.com/community/forums/silverlight/treeview/disable-drop-before-and-drop-after.aspx 
This blog says that it will be possible in the next service pack (which must be released by now). But I can't figure out how.

Thanks in advance

Ben

6 Answers, 1 is accepted

Sort by
0
Accepted
Petar Mladenov
Telerik team
answered on 03 May 2011, 05:08 PM
Hello Ben,

I prepared a sample project for you illustrating the desired approach. It basically follows this documentation article. Please let us know if this is exactly what you've expected. You can also check out the RadDragAndDropmanger help articles and demos.

Regards,
Petar Mladenov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ben
Top achievements
Rank 1
answered on 04 May 2011, 08:56 AM
Hello Petar,

The solution you provided works with a code behind file. What I forgot to say was that  I'm using telerik with the MVVM design pattern and Caliburn.Micro. If I attach the handler the way you provided it give me the following error: "Cannot convert from Telerik.windows.RoutedEvent to System.Windows.RoutedEvent".

In your solution you checked if the dropPosition is inside and ignore any other dropPostionType. I used that part in the workaround I currently have, which is:

Within the RadTreeView I disabled the previewLine and Tooltip.
I implemented the DragEnded en PreviewDragEnded events for the RadTreeView in my ViewModel
In the implementation of the PreviewDragEnded I set the DropPosition to DropPosition.Inside

public void PreviewDragEnded(RadTreeViewDragEndedEventArgs e)
{
    if (e.DraggedItems[0] != null && e.TargetDropItem.Item != null)
    {
        var dragDestinationItem = e.TargetDropItem;
        if (dragDestinationItem.DropPosition != DropPosition.Inside)
        {
            e.TargetDropItem.DropPosition = DropPosition.Inside;
        }
    }
    else
    {
        e.Handled = true;
    }
}


And in my DragEnded implementation the dropPostion is now always DropPosition,Inside

Regards,

Ben
0
RoadWarrior
Top achievements
Rank 1
answered on 24 Jul 2012, 05:44 AM
Petar.  Your demo illustrates a major issue with Telerik's drag & drop.  The vertical row space which triggers the "Drop In Item X" diminishes with each additional row.  So while it is relatively easy to trigger a drop into "Item A" while dragging over, it get more more difficult as you go down the list.  Check the demo, you will not be able to drop into beyond "Item F".

Please verify my findings.  Hopefully, you can provide a good workaround.  Thanks, ~Rick
0
Tina Stancheva
Telerik team
answered on 27 Jul 2012, 07:58 AM
Hi Rick,

I'm not sure I understand what you mean. I tested Peter's solution and I didin't encounter any difficulties while trying to drop inside any of the items. Can you please have a look at this screencast and let me know if I've missed something.

Also, can you please check if your browser is zoomed, as in older versions of the RadTreeView control, this used to cause issues when calculating the mouse position based on which the DragTooltip is displayed. 

Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
RoadWarrior
Top achievements
Rank 1
answered on 27 Jul 2012, 02:26 PM
Thank you Tina!  You are correct.  My browser was zoomed to 115% and am using Q1 2011.  Unfortunately, I am not sure I can upgrade at this time.  Is there a workaround short of an upgrade?  Thanks again.
0
Ziev
Top achievements
Rank 1
answered on 09 Oct 2012, 11:28 AM
Hi Ben,

Just wanted to thank you for sharing this little piece of code, which helped me solved my own problem:

I wanted to make the "Inside" position look and behave as an "After" position (including the preview line and all the rest).
In other words, to cancel having the Inside position and have only Before and After positions with a smooth transition between them (no gap).
Using your value override method did it!

I don't think I would have thought about it by myself otherwise... so thanks again for sharing.

Cheers,
Ziev
Tags
TreeView
Asked by
Ben
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Ben
Top achievements
Rank 1
RoadWarrior
Top achievements
Rank 1
Tina Stancheva
Telerik team
Ziev
Top achievements
Rank 1
Share this question
or