Solved

Silverlight Drag and Drop not working

Posted on 2011-03-16
3
1,113 Views
Last Modified: 2012-05-11
Hi,

I have a Silverlight 4 app.  In the app I have 2 DataGrids, I setup a MouseLeftButtonDown event on the DataGridRow to create a Label with info in it for a Drag'n'Drop event
        void grid_LoadingRow( object sender, DataGridRowEventArgs args )
        {
            args.Row.AddHandler( MouseLeftButtonDownEvent, new MouseButtonEventHandler( ( s, e ) => tableColumn_MouseLeftButtonDown( (FrameworkElement)s, e ) ), true );

            args.Row.AllowDrop = true;
            args.Row.Drop += new DragEventHandler( tableColumn_Drop );
        }

Open in new window


This works fine, I get a label that pops up when I hold the left mouse button down and I can drag this label anywhere I want.

As shown above, I also have an Drop event registered to grab the label if I drop it in the next door datagrid.  The problem now is, that when I drop something on the other DataGrid's Rows, they don't fire the Drop event.  If I drag a file from the file system and drop it there, it fires just perfectly.

The only thing I can come up with is that there must be some call to "register" a drag event.  I've tried creating DragEnter and Drop events on everything above the Target DataGridRow, being the Datagrid, StackPanels, Grids, even LayoutRoot and I've tried dropping different items but they're still not firing.  Only something coming in from outside the application registers

Thanks!
0
Comment
Question by:Cyber-Storm
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
saragani earned 500 total points
ID: 35835308
Are you doing a DragDrop.DoDragDrop anywhere in your code?
0
 

Author Comment

by:Cyber-Storm
ID: 35944020
I got around this eventually by simply finding the elements in the coordinates of where I release the item I'm dropping and if I hit a DataGridRow then I select it.

Sorry I didn't respond, I was on leave.  I never saw the dodragdrop before (this is the first time I dealt with drag 'n drop) in any of the examples I looked at so no, I didn't use it.  But I did briefly look into it and by searching for DoDragDrop I suddenly found what I should have the first time and then I'd probably never struggled.  Because of that I'll mark your post as the solution, thanks :)
0
 

Author Closing Comment

by:Cyber-Storm
ID: 35944034
I'm very disappointed that it took 2 months for any sort of response from experts exchange specially concidering how much I'm paying for it as opposed to a free site.  By paying for the service I really expect better service than the sites providing free service where you're relying on someone from the community to share their time for free.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now