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

Treeview Drag & Drop not Dropping

2 Answers 68 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Paul Tracy
Top achievements
Rank 1
Paul Tracy asked on 14 Aug 2009, 02:03 PM
Hi,

This is probably a case of a stupid mistake/misunderstanding on my part but I am unable to move the items in a treeview control on my silverlight 3 page.

I have added a RadTreeview control to my silverlight page and added an ItemSource of type List<String> for testing purposes (the strings represent file names).  The "files" show up in the treeview, they are selectable and draggable and the tooltip text informs of where the file drop point will be amongst the other files, however, when the mouse is released the file is not moved.  The examples I have seen both online and in the provided example solution do not show a method implementation required for the drop into the treeview (which they do for dropping into a grid or textbox) so ive assumed that this functionality is default in the control???  Or should I be implementing a drop method into the treeview???

I am running the following:
    
    VS 2008
    RadControls_for_Silverlight_2009_2_0812_DEV.msi
    Silverlight 3 (not beta)

FYI: Reason for doing this is because there is currently no way to re-order files in the filem upload control which I have seen mentioned in other forums discussions...

2 Answers, 1 is accepted

Sort by
0
Paul Tracy
Top achievements
Rank 1
answered on 14 Aug 2009, 03:27 PM
Ok... Purely by accident I have found the issue via a round about route.

Previously I had been adding the file one by one via the items.add(""); to one of a pair of list boxes.  I had set buttons to move the file(s) from the source box to the target box to order them, code would then clear the moved item from the source box.

When I decided to use the Treeview I decided to use a generic list of srings List<String> and use this as the ItemSource, this as seen from my previous post did not work.  I changed back to the list boxes for a proof of concept and left the generic list in.  When the clear method fired the debugger threw a read-only error which I guess is down to the binding between the listbox and the generic list.

It appears the same must be true for the Treeview but no error is thrown.
0
Tihomir Petkov
Telerik team
answered on 17 Aug 2009, 01:34 PM
Hi Paul,

The problem with binding to a List<string> collection is that this type of collection does not notify the treeview about changes to its items. If you bind the treeview to a ObservableCollection<string> you will have no problems dragging and dropping the items to shuffle their order.

Let me know if this info helps.

Greetings,
Tihomir Petkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
TreeView
Asked by
Paul Tracy
Top achievements
Rank 1
Answers by
Paul Tracy
Top achievements
Rank 1
Tihomir Petkov
Telerik team
Share this question
or