비교적 간단한 구현 : http://wildermuth.com/2009/02/09/Drag_and_Drop_in_Silverlight_2

public partial class Page : UserControl
{
  bool isDragging = false;
  Point offset;
  // ...
}

void theDragon_MouseLeftButtonDown(object sender,
                                   MouseButtonEventArgs e)
{
  // Mark that we're doing a drag
  isDragging = true;

  // Ensure that the mouse can't leave the dragon
  theDragon.CaptureMouse();

  // Determine where the mouse 'grabbed'
  // to use during MouseMove
  offset = e.GetPosition(theDragon);
}

void theDragon_MouseMove(object sender, MouseEventArgs e)
{
  if (isDragging)
  {
    // Where is the mouse now?
    Point newPosition = e.GetPosition(LayoutRoot);
    info.Text = string.Concat("Position: ",
                              newPosition.X,
                              " x ",
                              newPosition.Y);

    // Move the dragon via the new position less the offset
    theDragon.SetValue(Canvas.LeftProperty,
                       newPosition.X - offset.X);
    theDragon.SetValue(Canvas.TopProperty,
                       newPosition.Y - offset.Y);
  }
}

void theDragon_MouseLeftButtonUp(object sender, 
                                 MouseButtonEventArgs e)
{
  if (isDragging)
  {
    // Turn off Drag and Drop
    isDragging = false;

    // Free the Mouse
    theDragon.ReleaseMouseCapture();
  }
}

MSDN Drag & Drop 샘플 : http://msdn.microsoft.com/en-us/library/cc189066(VS.96).aspx HitTest를 이용해서 오브젝트 추적 : http://nickssoftwareblog.com/2008/10/07/silverlight-20-in-examples-part-drag-and-drop-inside-out/

드래그엔드롭 매니저 : http://www.codeplex.com/silverlightdragdrop
저작자 표시 비영리 동일 조건 변경 허락
Posted by 데모집팀 황리건