Solved

Silverlight Drag and Drop not working

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Several part series to implement Internet Explorer 11 Enterprise Mode
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

706 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

18 Experts available now in Live!

Get 1:1 Help Now