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

TreeViewItem Losing DragDropManager Events

4 Answers 45 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
WILLIAM
Top achievements
Rank 1
WILLIAM asked on 16 Jul 2014, 05:25 PM
Hello Telerik Team,

I have a weird situation.  I have a tree view with folders and sub folders.  I am subscribing to the TreeViewOnItemPrepared event and setting the AddDragInitializeHandler, AddDragLeaveHandler, AddDrogOverHandler, and AddDropHandler.  I know that the code in each of these events are correct because I can drag and drop.  However, If I drag over, but do not drop, and then drag out and let go (no drop); all of the event handlers are lost or unsubscribed to.  Subsequent drags, drag over, drop, and drag leave never fire.

Any Ideas on what may be causing this?

Thanks for your help!!!  

4 Answers, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 21 Jul 2014, 10:55 AM
Hello William,

I tried to reproduce the reported behavior on our side with our latest official release and it seems that the code works as expected. Could you please take a look at the attached project and try to reproduce the issue in it? Please feel free to change the code so that the issue can be reproduced. It will be great if you can send back the project, demonstrating the reported behavior. Also, it will be helpful if you provide us with exact steps which reproduce the behavior. It will help us track down the reasons behind the issue. 

Please note that I subscribe to the already handled events. This is needed because the RadTreeView control internally handles those events.

Regards,
Pavel R. Pavlov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
WILLIAM
Top achievements
Rank 1
answered on 21 Jul 2014, 01:29 PM
Thanks for the quick reply.  If I get a chance I'll take a look at your project.  I may discover what I'm doing incorrectly that way.  If I can reproduce it in your project, I'll send it back.

Thanks Again!
0
WILLIAM
Top achievements
Rank 1
answered on 23 Jul 2014, 06:41 PM
I haven't yet had a chance to look at your project, but I did add some code on my end to see if this fixes it.  On the ItemPrepared event, I subscribe to the following events: item.Click, item.Collapsed, item.Expanded, and item.LostFocus.  All of theses events fire correctly everytime, however, I still loose the DragDropManager events.  It's as if even though they have been set, they are lost or weren't added to the DragDropManager or something.  Once you loose the events, nothing will reset them.

Here is my code:
public void Initialize(RadTreeView treeView)
        {
            TreeView = treeView;
            TreeView.ItemPrepared += TreeViewOnItemPrepared;
        }
 
        private void TreeViewOnItemPrepared(object sender, RadTreeViewItemPreparedEventArgs e)
        {
            e.PreparedItem.Click += SetHandlers;
            e.PreparedItem.Collapsed += SetHandlers;
            e.PreparedItem.Expanded += SetHandlers;
            e.PreparedItem.LostFocus += SetHandlers;
             
            SetHandlers(e.PreparedItem);
        }
 
        private void SetHandlers(object sender, RoutedEventArgs routedEventArgs)
        {
            var item = routedEventArgs.OriginalSource as RadTreeViewItem;
            if (item == null) return;
 
            SetHandlers(item);
        }
 
        private void SetHandlers(object sender, RadRoutedEventArgs radRoutedEventArgs)
        {
            var item = radRoutedEventArgs.OriginalSource as RadTreeViewItem;
            if (item == null) return;
 
            SetHandlers(item);
        }
 
        private void SetHandlers(RadTreeViewItem treeViewItem)
        {
            DragDropManager.RemoveDragLeaveHandler(treeViewItem, OnItemDragLeave);
            DragDropManager.RemoveDragOverHandler(treeViewItem, OnItemDragOver);
            DragDropManager.RemoveDropHandler(treeViewItem, OnDrop);
            DragDropManager.AddDragLeaveHandler(treeViewItem, OnItemDragLeave);
            DragDropManager.AddDragOverHandler(treeViewItem, OnItemDragOver);
            DragDropManager.AddDropHandler(treeViewItem, OnDrop);                       
        }
0
Pavel R. Pavlov
Telerik team
answered on 24 Jul 2014, 07:26 AM
Hello,

Thank you for getting back to us. Unfortunately the provided information does not add clarification to your current implementation. I will still need to see your project, or one that replicates your scenario. I need to check if you correctly subscribe to the events. Furthermore, if the subscription is correct, I will need a project demonstrating the issue so that I will be able to investigate the reasons behind.

Sending me a project demonstrating the reported issue will be the easiest way.

Regards,
Pavel R. Pavlov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
TreeView
Asked by
WILLIAM
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
WILLIAM
Top achievements
Rank 1
Share this question
or