var draggedItem = DragDropPayloadManager.GetDataFromObject(e.Data, "DragData");
var droppedItem = (e.OriginalSource as FrameworkElement).ParentOfType<RadTreeViewItem>();
//remove all selections
(sender as RadTreeView).SelectedItem = null;
//select just droppeditem
if (draggedItem is PeopleModel.PeopleDetail)
droppedItem.IsSelected = true;
e.Effects = DragDropEffects.None;
e.Handled = true;
Hi, i have a simple RadListBox to RadTreeView drag and drop, if i run, the event onDrop is called twice, if i debug, at the end of first ondrop return me an exception:
DragEventArgs.cs not found
i post my code:
2 Answers, 1 is accepted
answered on 10 Feb 2014, 07:11 AM
From the code snippets you've sent it looks like you have attached DragOver and Drop handlers on the whole RadTreeView. In this case when you drop the listBoxItem on any RadTreeViewItem, Drop handler will be called for any visual element (RadTreeViewItem first, RadTreeView after that). In order to prevent this behavior you have to handle drop operation (set e.Handled = true in Drop handler). This way the event will not be raised up the visual tree.
As for the exception while debugging, is it really an exception or you are using F10 key and Visual Studio is searching for the next operation, which is in DragEventArgs.cs file (part of our code)? If it is exception, could you send a sample project reproducing the behavior as based on the current one we were unable to reproduce it.
Hope this helps. Feel free to contact us in case you have any problems or concerns.
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely. Sign up for Free application insights >>