Solved

Silverlight Drag and Drop not working

Posted on 2011-03-16
3
1,123 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

#Citrix #Internet Explorer #Enterprise Mode #IE 11 #IE 8
This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
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…
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

810 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