How to Restrict the ListBoxitem to drop from ListBox to GridView

4 posts, 0 answers
  1. Veeraguru
    Veeraguru avatar
    9 posts
    Member since:
    Jul 2013

    Posted 28 Aug 2013 Link to this post

    Hi Team,

    I am using following code to implement drag and drop the items with in the listbox. But in the same View i have GridView control. If i drag and drop the listboxitem into the GridView my item is deleted from the Listbox. I should restrict this. I am following MVVM pattern.

    Please give me a solution.

    My Code:

    <drag:ListBoxDragDrop.Behavior>
            <drag:ListBoxDragDropBehavior AllowReorder="True" ItemType="{x:Type Mod:Model}"></drag:ListBoxDragDropBehavior>
            </drag:ListBoxDragDrop.Behavior>
    T
    hanks in Advance.
  2. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 02 Sep 2013 Link to this post

    Hello,

    By design when items are dragged and dropped from the control they are removed from the source control. In order to customize that logic you will need to create a custom ListBoxDragDropBehavior and override its DragDropCompleted.

    All you need to do is create a class that inherits the ListBoxDragDropBehavior class, override its DragDropCompleted and remove the call to the base method (leave the DragDropCompleted blank). The next code snippet shows how such DragDropBehavior should look like:
    public class CustomListBoxDragDropBehavior : ListBoxDragDropBehavior
    {
        public override void DragDropCompleted(DragDropState state)
        {
     
        }
    }


    Regards,
    Vladi
    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Veeraguru
    Veeraguru avatar
    9 posts
    Member since:
    Jul 2013

    Posted 23 Sep 2013 Link to this post

    Hello,

    Can you please provide me a sample project?

    Regards,
    Veeraguru
  5. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 25 Sep 2013 Link to this post

    Hello,

    We created a sample project for you that shows the previously mentioned approach.

    You can find the project attached to my response, hope this is helpful.

    Regards,
    Vladi
    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