TreeViewItem Losing DragDropManager Events

5 posts, 0 answers
  1. WILLIAM
    WILLIAM avatar
    134 posts
    Member since:
    Jun 2012

    Posted 16 Jul 2014 Link to this post

    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!!!  
  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 21 Jul 2014 Link to this post

    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.
     
  3. DevCraft banner
  4. WILLIAM
    WILLIAM avatar
    134 posts
    Member since:
    Jun 2012

    Posted 21 Jul 2014 in reply to Pavel R. Pavlov Link to this post

    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!
  5. WILLIAM
    WILLIAM avatar
    134 posts
    Member since:
    Jun 2012

    Posted 23 Jul 2014 Link to this post

    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);                       
            }
  6. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 24 Jul 2014 Link to this post

    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.
     
Back to Top
DevCraft banner