Hi I'm trying to implement a drag and drop functionality between a treelistview and a radgridview
No problem here
Where I get stuck is when I'm passing over other control, than the treelistview or radgridview.
I just want for "IsDropPossible" to be false when I'm not over a manage control.
I can't found a simple way to do it without adding each control to RadDragAndDropManager.AddDropInfoHandler
Any advice ?
Thanks
6 Answers, 1 is accepted
You can use the DragQuery event to validate the drop.
Subscribe to it by
RadDragAndDropManager.AddDragQueryHandler(
this
, OnDragQuery);
You can check the current destination in the handler by accessing eventArgs.Options.Destination, and if it doesn't suit your needs set the eventArgs.QueryResult to false.
Hope this helps!
Best wishes,
Nik
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Odly it's called when starting a drag from the radgridview and not from the treelistview
But this is still not resolving my problem, even for the radgridview drag, as soon as I got out of my "dropable zone" the event is not called anymore, so i can't set the query result to false.
I may be doing something wrong, if you could give me a sample project, would really appreciate it
Thanks in advance.
You are absolutely right. The proper place to put such a logic is in the DropQuery handler.
I am attaching a simple application demonstrating a simple scenario on how to accomplish a similar behavior.
You can see that in the DropQuery handler I am checking the name of the destination control, and if it isn't what I expect I simply set the query result to false. Of course you can do a lot more than that, and modify it in a way that suits the requirements that you have.
I hope this helps!
Nik
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
I wish for a visual result to show users if they can drop a row in an area (gridview) or not (listbox, grid, button, ect)
if you modifiy your xaml like this
<StackPanel Orientation="Horizontal">
<telerik:RadGridView x:Name="gridView"
Width="200"
telerik:RadDragAndDropManager.AllowDrop="True"
RowStyle="{StaticResource draggableRowStyle}"/>
<telerik:RadTreeListView x:Name="treeView"
Width="0"
telerik:RadDragAndDropManager.AllowDrop="True"
RowStyle="{StaticResource draggableTreeRowStyle}"/>
<ListBox Width="200"/>
<telerik:RadTreeListView x:Name="treeView1"
Width="200"
telerik:RadDragAndDropManager.AllowDrop="True"
RowStyle="{StaticResource draggableRowStyle}"/>
</StackPanel>
I just "replace" the "treeView" by a listbox, simple regular control. When you drag over the listbox, no event => How do i set the query result to false (btw don't know why, but in your exmemple, i can't have a tooltip icon sign that show if it's dropable or not)
Do I really need to add a "telerik:RadDragAndDropManager.AllowDrop="True"" on every controls (a lot!) of my silverlight application?
Thanks
Unfortunately if you want the events to raise, you will have to add "telerik:RadDragAndDropManager.AllowDrop="True"", either in each control definition, or in an implicit style. Other than that, you cannot drop on a control with a AllowDrop = "True". As for the visual indications, you can use the DragCue functionality to obtain the desired behavior.
Hope you find this information helpful!
Nik
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Just in case someone do have the same problem :
In the DropInfo I'm checking if the "droping zone" is OK or NOT but I wasn't taking in acount the e.Options.Status
So I just added a check on e.Options.Status != DragStatus.DropImpossible before touching any dragcue