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

Treeview Drag and Drop with MVVM

1 Answer 165 Views
This is a migrated thread and some comments may be shown as answers.
Tushar Gupta
Top achievements
Rank 1
Tushar Gupta asked on 20 Apr 2010, 08:53 PM
We are implementing drap and drop fucntioanlity using RAdTreeView, things work just fine, but the concern that I have that I cant use MVVM pattern for databinding. Below is XAML Snippet what I am trying to do, the bold stuff is used for binding Event to the Command.
As DragInfo is the dependency property on RADDaragDropMAnager and not on RADTreeView this blows up as soon as page gets loaded, is there a way to accomplish this? If DragInfo would have event of RadTreeView this would have worked without any issue as
I am using this concept all over the place with other controls.



telerikNavigation:RadTreeView x:Name="tv" IsLineEnabled="True"















ItemsSource="{Binding Source={StaticResource EntityDataSource}}"



ItemTemplate="{StaticResource LOBTemplate}"



HorizontalAlignment="Center" VerticalAlignment="Center"











<windinteract:EventTrigger EventName="DragInfo">




<beh:EventToCommand MustToggleIsEnabledValue="True" Command="{Binding SendMessage}" CommandParameterValue="Click" />













</telerikNavigation:RadTreeView >



1 Answer, 1 is accepted

Sort by
Tina Stancheva
Telerik team
answered on 23 Apr 2010, 04:29 PM
Hi Tushar Gupta,

The RadTreeView has rich drag-and-drop functionality that you can take advantage of, instead of using the RadDragAndDropManager.

However, if your scenario requires you to use the RadDragAndDropManager, you can add the appropriate event handlers to the RadTreeView, like so:
myTreeView.AddHandler(RadDragAndDropManager.DragQueryEvent, new EventHandler<DragDropQueryEventArgs>(OnDragQuery), true);
myTreeView.AddHandler(RadDragAndDropManager.DragInfoEvent, new EventHandler<DragDropEventArgs>(OnDragInfo), true);
Please keep in mind that in order to add these handlers you need to add an using directive to the Telerik.Windows namespace in the .cs file, like so: using Telerik.Windows;

Also you don't need to set the dragDrop:RadDragAndDropManager.AllowDrag="True" in the RadTreeView declaration. Adding the above event handlers and the IsDragDropEnabled property to "True" is enough.

I hope this information will help you implement your scenario.

Please let us know if you need more info or if your project requires a different approach.

Sincerely yours,
Tina Stancheva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Asked by
Tushar Gupta
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question