DragDropManager OnDrop exception and fire twice

2 posts, 0 answers
  1. Aldo
    Aldo avatar
    42 posts
    Member since:
    Feb 2011

    Posted 05 Feb 2014 Link to this post

    public PanelAssociation(DateTime Date)
                date = Date;
                Day.Text = date.ToShortDateString();
                DragDropManager.AddDropHandler(ListExtern, OnDrop);
                DragDropManager.AddDragOverHandler(ListExtern, OnDragOver);
            private void OnDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
                var draggedItem = ((DataObject)e.Data).GetData("DragData");
                var droppedItem = (e.OriginalSource as FrameworkElement).ParentOfType<RadTreeViewItem>();
                PeopleModel.PeopleDetail people = draggedItem as PeopleModel.PeopleDetail;
                OrderModel.OrderHead head = droppedItem.Item as OrderModel.OrderHead;
                //create program
                OrderModel.OrderService.CreateProgramByID(head, date, people.id);
            private void OnDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
                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. Rosen Vladimirov
    Rosen Vladimirov avatar
    640 posts

    Posted 10 Feb 2014 Link to this post

    Hi Aldo,

    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.

    Rosen Vladimirov
    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 >>
Back to Top