Home > Silverlight > Drag & Drop DataGridRows

Drag & Drop DataGridRows

Here is the sample code for drag & drop of the DataGridRows I did couple of months back updated to work in beta 2

We dont get mouse events so we have to use another canvas or something which will sit on top of the datagrid at the same location as the datagird, we set the zIndex to a higher number

   <Canvas Width=”300″ x:Name=”datagrid1Canvas”
 Canvas.ZIndex=”2″
        Margin=”80,85,0,10″
        Height=”250″
        Background=”Transparent”/>

you can download the source here

Categories: Silverlight
  1. October 29, 2008 at 9:44 am | #1

    Fantastic post, this is amazing…

  2. lee
    October 29, 2008 at 10:51 am | #2

    Thanks

  3. chinkul
    November 7, 2008 at 11:14 pm | #3

    Does this work on SL2? I am not able to open the project file.
    Please help me.

    Thanks

  4. chinkul
    November 7, 2008 at 11:24 pm | #4

    I want to be able to move the rows around the same grid. Is it possible to do? If so can you please post the code in SL2.
    Thanks

  5. lee
    November 8, 2008 at 5:58 am | #5

    I will update and post

  6. lee
    November 8, 2008 at 6:18 am | #6
  7. Chinkul
    November 8, 2008 at 6:37 am | #7

    Thanks Lee, It works beautifully.

    I have 2 questions:

    1. Why is the drag and drop working from top to bottom only. Why is it not working when i try to move the bottom row to top? Can we make that working?

    2. Is there a possiblity to select more than one row and move all the selected rows, instead of moving each row at a time..?

    Thanks Lee, you are doing great job.

  8. lee
    November 8, 2008 at 11:41 am | #8

    1. In the Page_MouseLeftButtonUp handler we have a check
    if (horizDrag > minimumHorizontalDragDistance || vertDrag > minimumVerticalDragDistance)

    it is because of this, drag& drop wont occur for small distances
    2. it should be possible, but did not try

  1. June 17, 2008 at 10:22 pm | #1