Solved

Silverlight Drag and Drop not working

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
"Emulate" TAB key when press Enter Key 3 65
Name Space error VS2015 1 35
Mozilla Favorites 10 29
can not get an online video to playback in Google Chrome 4 37
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
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…

680 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