Drag and drop fails of destination does not have a Background color set

2 posts, 0 answers
  1. Matt Greer
    Matt Greer avatar
    30 posts
    Member since:
    May 2010

    Posted 30 Nov 2010 Link to this post

    Ugh. I just spent several hours trying to figure out why my DnD was not working. It turns out if a destination control does not have its Background property set, the DnD will fail and result in DropImpossible.

    Here is a sample app demonstrating the problem:

    <UserControl x:Class="TelerikDNDTest.MainPage"
        mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
        <Grid x:Name="LayoutRoot">
            <StackPanel Margin="80">
                <ListBox x:Name="_myListBox" Width="200" Height="100" BorderBrush="Black" BorderThickness="1">
                <TextBlock x:Name="_myTextBlock" Text="No dnd yet" HorizontalAlignment="Center" />

    using System.Windows.Controls;
    using Telerik.Windows.Controls.DragDrop;
    namespace TelerikDNDTest
        public partial class MainPage : UserControl
            private void OnDragQuery(object sender, DragDropQueryEventArgs e)
                if (e.Source == _myListBox)
                    e.QueryResult = true;
                    ContentControl cue = new ContentControl();
                    TextBlock tb = new TextBlock();
                    tb.Text = "Dragging!";
                    cue.Content = tb;
                    e.Options.Payload = "dragging";
                    e.Options.DragCue = cue;
                    e.Handled = true;
            private void OnDropQuery(object sender, DragDropQueryEventArgs e)
                if (e.Options.Status == DragStatus.DropDestinationQuery && e.Options.Source == _myListBox)
                    e.QueryResult = !ReferenceEquals(e.Options.Source, e.Options.Destination);
                    e.Handled = (bool)e.QueryResult;
            private int _successCount = 0;
            private void DropSuccess()
                _myTextBlock.Text = "DND Success " + (++_successCount);
            private void OnDropInfo(object sender, DragDropEventArgs e)
                if (e.Options.Status == DragStatus.DropComplete)
                    if (e.Options.Source == _myListBox)
                        e.Handled = true;
            private void SetupDragAndDrop()
                RadDragAndDropManager.AddDragQueryHandler(this, OnDragQuery);
                RadDragAndDropManager.AddDropQueryHandler(this, OnDropQuery);
                RadDragAndDropManager.AddDropInfoHandler(this, OnDropInfo);
                RadDragAndDropManager.SetAllowDrag(_myListBox, true);
                RadDragAndDropManager.SetAllowDrop(LayoutRoot, true);
            public MainPage()

    In this sample app as is, the drag and drop from the listbox out into the parent grid will never succeed. However, if you give the parent Grid (LayoutRoot in this example) a Background color (even Transparent works fine), then the drag and drop will succeed.

    Is there something I am doing wrong to cause this?
  2. Maya
    Maya avatar
    4062 posts

    Posted 01 Dec 2010 Link to this post

    Hi Matt Greer,

    The behavior you are getting is the expected one in the Silverlight platform. The reason is that no events are raised in case no background is set. As you successfully figured it out, even setting the Background to Transparent does the job.

    Kind regards,
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
Back to Top