Drag from tree to border

2 posts, 0 answers
  1. Justin Lee
    Justin Lee avatar
    149 posts
    Member since:
    Dec 2009

    Posted 10 Jan 2014 Link to this post

    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>
  2. Nick
    Admin
    Nick avatar
    593 posts

    Posted 15 Jan 2014 Link to this post

    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 >>
  3. DevCraft banner
Back to Top