DragAndDrop - restrict to ReorderOnly?

2 posts, 0 answers
  1. Mat
    Mat avatar
    3 posts
    Member since:
    Jun 2012

    Posted 26 May 2014 Link to this post

    I have a couple of RadListViews - they are same except for they visualize different item collections. I need to have Draop and drop functionality to Reorder items inside list view, but I want to disallow dragging and dropping items from one list to another.

    How can I accomplish this?
  2. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 27 May 2014 Link to this post

    Hello Mat,

    You could easily achieve the desired by implementing a custom ListBoxDragDropBehavior which inherits from the default ListBoxDragDropBehavior. You will need to override the CanDrop method in order to check whether the drop will be inside of another control and if so to return false:

    public override bool CanDrop(DragDropState state)
    {
        if (!state.IsSameControl)
        {
            return false;
        }
     
        return base.CanDrop(state);
    }

    For more details about the ListBoxDragDropBehavior please check the following article from our online help documentation:
    http://www.telerik.com/help/wpf/radlistbox-features-dragdrop.html

    I have also attached a sample project which demonstrates the exact approach.

    Hope this will work for you.

    Regards,
    Kalin
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top