Drag Files to WPF Control

4 posts, 0 answers
  1. Martin
    Martin avatar
    4 posts
    Member since:
    May 2011

    Posted 08 Sep 2014 Link to this post

    Hello,

    I want to drag items from the Explorer (i.e. files) to wpf controls. But I have no idea how to set the drop preview line and the drag tooltip.

    Is there a way to achieve this.

    Thanks in advance.

    Best Regards,
    Martin
  2. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 08 Sep 2014 Link to this post

    Hello Martin,

    Thank you for contacting us.

    Could you please share some more detail regarding the exact requirement? Which WPF controls are you using and what exactly mean by "drop preview"?

    As for the DragVisual - by default it is managed from the source of the drag drop operation which in your case would be the Explorer and you can modify it anyhow. However what you can do would be to use a ToolTip in order to display information about the dragged object and implement custom logic in order to keep it shown and positioned correctly when dragging over the WPF control. You can get the information about the dragged item using our DragDropPayloadManager as shown below:

    if (DragDropPayloadManager.GetDataPresent(e.Data, DataFormats.FileDrop.ToString()))
    {
        string[] files = (string[])DragDropPayloadManager.GetDataFromObject(e.Data, DataFormats.FileDrop);
        ...
    }

    Hope this will help you to achieve the desired. If you have any further questions let us know.

    Regards,
    Kalin
    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. UI for WPF is Visual Studio 2017 Ready
  4. Martin
    Martin avatar
    4 posts
    Member since:
    May 2011

    Posted 09 Sep 2014 in reply to Kalin Link to this post

    Hello Kalin,

    I wanted to implement Drag and Drop of files to RadDataTree. When you start dragging a file from the Explorer or Desktop and drag it over a RadTreeView, we want to see the same DragVisual as if we would have dragged TreeViewItems inside the tree.
    see http://www.telerik.com/help/wpf/radtreeview-features-drag-and-drop.html

    Thanks in advance.

    Best regards,
    Martin
  5. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 12 Sep 2014 Link to this post

    Hello Martin,

    I'm afraid that the desired functionality is only present whenever dragging inside of the TreeView control. When using the DragDropManager to perform the drag operation the drop indication line won't be present. However you can try to implement it on your own. You would need to add borders below and above the TreeViewItems (using ItemTemplate) and hide them. Afterward using attached behavior for each TreeViewItem you can show and hide the lines on DragOver. Note that you would need to calculate the position of the mouse cursor somehow so you can know which line to show - the top one or the bottom one.

    Hope this will help you.

    Regards,
    Kalin
    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