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

Remove the "not allowed" icon on drag

2 Answers 611 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Jacob
Top achievements
Rank 1
Jacob asked on 22 May 2017, 12:02 PM

Hello Telerik,

 

I am implementing a feature which consists of a list of user controls that can be dragged to dock panels.

however, as you can see in the attached picture, there is this red "not allowed"-like icon showing, although the functionality works fine.

I just need to remove that icon. is there a way to do so?

 

Thank you

2 Answers, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 25 May 2017, 10:32 AM
Hi Jacob,

To hide the icon you can change the DropAction of the drag payload of the treeview. To do this you can subscribe the drop target to the DragDropManager.DragOver event. Then get the TreeViewDragDropOptions provided by the event arguments and set their DropAction to a value different than None.

For example:
DragDropManager.AddDragOverHandler(this.dropTargetControl, OnDropTargetDragOver, true);

private void OnDropTargetDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
{
    var options = DragDropPayloadManager.GetDataFromObject(e.Data, TreeViewDragDropOptions.Key) as TreeViewDragDropOptions;
    if (options != null)
    {
        options.DropAction = DropAction.Copy;               
        options.UpdateDragVisual();
    }
}
You can also use the DragEnter and DragLeave of DragDropManager instead of DragOver. Check the attached project for a sample implementation.

Alternatively you can get the DragVisual (TreeViewDragVisual) element from the TreeViewDragDropOptions and set its IsDropPossible to True.

If you want to completely hide the tooltip that shows the icon you can get the DragVisual 
var dragVisual = (TreeViewDragVisual)options.DragVisual;
dragVisual.DragTooltipVisibility = Visibility.Collapsed;

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Jacob
Top achievements
Rank 1
answered on 26 May 2017, 09:15 AM

Thank you Martin. Your solution works perfectly.

Tags
DragAndDrop
Asked by
Jacob
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Jacob
Top achievements
Rank 1
Share this question
or