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

Drag from tree to border

1 Answer 38 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Justin Lee
Top achievements
Rank 1
Justin Lee asked on 10 Jan 2014, 02:37 PM

I need a little help.  I have a RadTreeView and want to be able to drag 1 item into an area (a border control).  I set AllowDrop to true, and added a DropHandler.  The DropHandler event fires, and I am able to get the dragged item and add content to the border.  This works just fine.  However, when dragging over the border, the not-allowed icon is displayed (circle with line), and the Drag cue is empty.

How can I make the drag cue say something like "drop in section a", and not show the not-allowed icon?

public TestControl()
{
  InitializeComponent();
  DragDropManager.AddDragOverHandler(this.brdDropArea, OnDragOver);
  DragDropManager.AddDropHandler(this.brdDropArea, OnDrop);
}
 
private void OnDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
{
  var x = DragDropPayloadManager.GetDataFromObject(e.Data, TreeViewDragDropOptions.Key) as TreeViewDragDropOptions;
  if (x != null)
  {
    //  ?????
    x.DragVisual = new TextBlock() { Text = "Drop Here" };
    x.DropAction = DropAction.Copy;
    x.UpdateDragVisual();
    e.Effects = DragDropEffects.All;
    e.Handled = true;
  }
}    
 
private void OnDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
{
   // Handle Drop Code
)
<StackPanel>
  <telerik:RadTreeView x:Name="treeView" AllowDrop="False"
     telerik:TreeViewSettings.DragDropExecutionMode="New" >
  </telerik:RadTreeView>
  <Border x:Name="brdDropArea" Width="200" Height="20" BorderBrush="#666666"
    BorderThickness="1" AllowDrop="True" />
</StackPanel>

1 Answer, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 15 Jan 2014, 10:52 AM
Hi Justin,

There are a couple of approaches you can try. 

The first is to use the DragOver event and set the Effects to all in order to avoid the forbidden icon. 

The second is to try and set a background to the Border(Transparent for example), and see if that helps. The problem is that some primitives like the border are not HitTestVisible unless a Background has been set(has to be different from null).

Hope this helps! 

Regards,
Nik
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
DragAndDrop
Asked by
Justin Lee
Top achievements
Rank 1
Answers by
Nick
Telerik team
Share this question
or