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

DragDrop Payload

2 Answers 81 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gerrit Fölster
Top achievements
Rank 1
Gerrit Fölster asked on 23 Mar 2012, 09:57 AM
Hi Telerik Team,

I'm using a DropQuery handler on a my treeview:
TreeViewControl.AddHandler(RadDragAndDropManager.DropQueryEvent, new EventHandler<DragDropQueryEventArgs>(OnDropInsideTreeViewDropQuery),true);

 
private void OnDropInsideTreeViewDropQuery(object sender, DragDropQueryEventArgs e)
   {
    List<MyEntity> draggedTasks = ((Collection<object>)e.Options.Payload).Cast<MyEntity>().ToList();
   }
Sometimes the e.Options.Payload contains a number of MyEntity items (as expected) and an additional item of type object which leads to an exception when calling .Cast<MyEntity>.

The whole TreeView is databound via HierarchicalDataTemplate, IsSelected and IsExpanded are also bound via ContainerBindings. I'm dragging within the tree, no other controls are involved.

I'm using Telerik 2011 Q3 on Silverlight 5.
Unfortunately I'm not always able to reproduce this behavior. Can you give any hints on this issue?

Thanks, 
Gerrit

2 Answers, 1 is accepted

Sort by
0
Accepted
Hristo
Telerik team
answered on 27 Mar 2012, 12:22 PM
Hello,

I've myself encountered similar situations (not in drag and drop scenario) when the related data item (RadTreeViewItem.Item) with the RadTreeViewItem container is just a object.

This could happen when ItemContainerGenerator has generated a container for the data item but the container is not yet initialized correctly. These occasions are mainly related with the selection logic which makes me believe there is something wrong going inside the selection and related bindings.

Could you try to simulate the issue when there are no bindings to the IsSelected property?

Also, could you check if the count of dragged items is the correct one or there is one additional item?
If the count is greater than the real dragged items count, I  would suggest you to just filter the collection.

Hope this helps. I'm looking forward for your post on the topic.

Greetings,
Hristo
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Gerrit Fölster
Top achievements
Rank 1
answered on 02 Apr 2012, 04:18 PM
Hello again,

as you suggested, I removed the bindings to the IsSelected property and the problem no longer occurs.
As a workaround I now handle SelectionChanged on the treeview and set the IsSelected property on my entities according to the AddItems and RemovedItems parameters.

Thank you for pointing me in the right direction,
Gerrit
Tags
TreeView
Asked by
Gerrit Fölster
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Gerrit Fölster
Top achievements
Rank 1
Share this question
or