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

Drag Files to WPF Control

3 Answers 166 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 08 Sep 2014, 07:52 AM
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

3 Answers, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 08 Sep 2014, 12:02 PM
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.
 
0
Martin
Top achievements
Rank 1
answered on 09 Sep 2014, 12:53 PM
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
0
Kalin
Telerik team
answered on 12 Sep 2014, 10:27 AM
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.
 
Tags
DragAndDrop
Asked by
Martin
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Martin
Top achievements
Rank 1
Share this question
or