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

How to Restrict the ListBoxitem to drop from ListBox to GridView

3 Answers 56 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Veeraguru
Top achievements
Rank 1
Veeraguru asked on 28 Aug 2013, 12:16 PM
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.

3 Answers, 1 is accepted

Sort by
0
Vladi
Telerik team
answered on 02 Sep 2013, 11:21 AM
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 >>
0
Veeraguru
Top achievements
Rank 1
answered on 24 Sep 2013, 04:51 AM
Hello,

Can you please provide me a sample project?

Regards,
Veeraguru
0
Vladi
Telerik team
answered on 25 Sep 2013, 11:17 AM
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 >>
Tags
General Discussions
Asked by
Veeraguru
Top achievements
Rank 1
Answers by
Vladi
Telerik team
Veeraguru
Top achievements
Rank 1
Share this question
or