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

bind QueryResult into ViewModel

1 Answer 61 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Greg Brondo
Top achievements
Rank 1
Greg Brondo asked on 13 Jan 2010, 09:05 PM
First, I may need correction in my belief that finding out if a drop is possible is done in the DropQueryHandler by setting e.QueryResult. As I understand if the result is true then a drop is possible and if not, it is not possible. If this isn't the case, can someone explain what is the case to me?

Also, I would prefer to make it so that I can bind this to an ICommand object inside my Xaml. Has anyone done such a thing? I don't mind making a new class that perhaps inherits from the ListBox control to add said functionality, but if this could be done through extension methods that would be even better. (Much like some have done to allow a button to bind to an ICommand.

It would really make my day to hear that Telerik has plans to implement this type of functionality in a future version given that full ICommand support should be in place for Silverlight 4.

1 Answer, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 13 Jan 2010, 11:24 PM
Hello Greg Brondo,

Yes, I can confirm that the QueryResult defines whether a drop will be possible.

Databinding directly would of course not be possible but you are right that this can happen with some kind of attached property.

Binding to an ICommand is also possible and will work in simple scenarios but there are some things that need to be addressed.

1. A DragDrop operation has two parameters, a Drop Target and a payload. This can be solved by binding a command for each object but creating a separate delegate command for each drop target seems like an overkill. An alternative may be to create a special command that will handle this scenario.

2. DragDrop normally has feedback, quite possibly some kind of text. The default command does not provide for this. Often "Drop Possible" / "Drop impossible" feedback is needed.

3. Normally the DragQuery needs to be handed as well. Should there be a separate command that acts when an object is about to be dragged (CanExecute) and when it is dropped (Execute)?

We do not plan to add Command support to the DragDrop just yet but I will be happy if our discussion here will produce something that is useful in these scenarios for other people as well.

I quickly put a basics of the idea in practice. You can see the result in the attached project. It is far from complete but it is a start.

What do you think about the above points?

Best wishes,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
DragAndDrop
Asked by
Greg Brondo
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Share this question
or