Dropping files from Explorer to RadTreeView using DragDropManager

9 posts, 0 answers
  1. Valerie
    Valerie avatar
    36 posts
    Member since:
    Nov 2011

    Posted 21 Jan 2013 Link to this post

    I have drag/drop working when I drag items from a RadGridView to a RadTreeView using your examples of a separate Behavior class (setting the DependencyProperty IsEnabled=true). Now I am trying to drag items from Windows Explorer onto the same RadTreeView. But the cursor always shows the 'no' circle with a slash through it and it never calls any of the methods in my behavior class.

    My xaml for the tree simply has the DP set on the RadTreeView.
    <telerik:RadTreeView SelectionMode="Single" x:Name="foldersTree"
    ItemsSource="{Binding Items}
    ItemContainerStyle="{StaticResource ItemContainerStyle}"
    IsLoadOnDemandEnabled="True"
    uiExt:RadTreeViewDragDropBehavior.IsEnabled="True">


    I see postings where people who are using the RadDragAndDropManager are able to do this. But how can I do it with the newer DragDropManager?
    Thanks, Valerie

  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 22 Jan 2013 Link to this post

    Hi Valerie,

    Basically you have to subscribe to the DragOver and Drop events and perform you custom logic in their handlers. Keep in mind that you will have to listen for already handled events because the RadTreeView control handles some of them. In the DragOver handler you can allow dropping in the RadTreeView control by setting the e.Effects property. That means that in the Drop handler you can handle the drop operation and add the dropped item to the desired position. I implemented the described approach in the attached project. You can use it as a basic start and further customize it corresponding to your needs. Please take a look at it and let me know if it works for you.

    Regards,
    Pavel R. Pavlov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Valerie
    Valerie avatar
    36 posts
    Member since:
    Nov 2011

    Posted 22 Jan 2013 Link to this post

    I already have a DependencyProperty applied to the RadTreeView that uses the DragDropManager to setup callbacks. (I got this from other Telerik examples that show the use of mvvm with drag and drop.) I use this currently for dragging/dropping from my RadGridView to this tree. And this code already has the same calls that your codebehind has, such as AddDragOverHandler and AddDropHandler.

    This DP approach works for dragging from the grid to the tree and works great. But not from Explorer.
    So I then added the following to my xaml in addition to my DP. But adding it causes my previously working drag/drop from the grid to stop working. So how can I set it up so I can drag from either the grid or Explorer to the same RadTreeView?
         IsDragDropEnabled="True"
         AllowDrop="True"

  5. Valerie
    Valerie avatar
    36 posts
    Member since:
    Nov 2011

    Posted 22 Jan 2013 Link to this post

    I just tried the project you sent. I had assumed it would work which was why I was trying to merge its concept into what I already have. However, this project doesn't even work. If I drag an item from Explorer over any of the folders the cursor is a circle with a line through it and it doesn't stop in any of the callbacks. Only if you try to drag a folder over another folder does it respond. But that's not what I need; I need to be able to drag something from outside my application, from Windows Explorer onto the RadTreeView.
  6. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 23 Jan 2013 Link to this post

    Hello,

    I am not sure that I understand what you mean when you say the project is not working. Please check this screen cast out and see how it behaves on our side.  In order to understand you I will kindly ask you to modify the previously attached project and send it back to me so I will be able to further investigate your issue.

    Regards,
    Pavel R. Pavlov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  7. Valerie
    Valerie avatar
    36 posts
    Member since:
    Nov 2011

    Posted 23 Jan 2013 Link to this post

    After viewing your video, which indeed does show dragdrop working from Explorer, I recalled that the application can not be running as admin when attempting to work with Explorer. I was running your project from within VS which I open as admin. I instead ran your app directly and indeed the drag and drop from Explorer does work. Sorry for that confusion.

    When I try the same thing from my application though (remember it is using a DependencyProperty to setup the DragDropManager) though it still does not work. You see the circle with the line through it. I tried adding the 2 properties IsDragDropEnabled=true and AllowDrop=true with no other change and it still does not work.

    To demonstrate this I have attached the DragDrop project that I received from Telerik. When you run this you will see that you can't drop files from Explorer. Adding IsDragDropEnabled=true and AllowDrop=true doesn't help but does break the dragging from the grid. Uh, it looks like I'm not allowed to attach a zip. So please tell me how I can send that to you.
  8. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 24 Jan 2013 Link to this post

    Hello Valerie,

    Thank you for getting back to us. In your case, I think it would be best to start a support ticket in which you will be able to attach your project. Also, if you can attach a solution demonstrating the approach you use to implement the drag/drop operations between the RadTreeView and the RadGridView and your issues in it, we will be able to better assist you. And if it's hard for you to strip down your solution, you can try to modify the solution Pavel sent to demonstrate your drag/drop logic better.

    Thank you in advance.

    Kind regards,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  9. Valerie
    Valerie avatar
    36 posts
    Member since:
    Nov 2011

    Posted 01 Feb 2013 Link to this post

    Hi Tina,
    I think all my problems were related to UAC. Even when I tried to rule that out I think a variety of factors conspired to make me think that I wasn’t running as Admin when I was. I know I have a case where it wouldn't work when it should have but I can't reproduce it so I'm chalking it up and hoping for the best going forward. 
    Thanks for your help, Valerie
  10. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 05 Feb 2013 Link to this post

    Hi Valerie,

    It does seem that the issue is caused by the settings on your machine. However, if you manage to reproduce it in a sample solution and you feel it is caused by the settings of the RadControls, please let us know so that we can assist you in resolving it.

    All the best,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
UI for WPF is Visual Studio 2017 Ready