DragDrop.DoDragDrop(DependencyObject, Object, DragDropEffects) 메서드

정의

끌어서 놓기 작업을 시작합니다.

public:
 static System::Windows::DragDropEffects DoDragDrop(System::Windows::DependencyObject ^ dragSource, System::Object ^ data, System::Windows::DragDropEffects allowedEffects);
[System.Security.SecurityCritical]
public static System.Windows.DragDropEffects DoDragDrop (System.Windows.DependencyObject dragSource, object data, System.Windows.DragDropEffects allowedEffects);
public static System.Windows.DragDropEffects DoDragDrop (System.Windows.DependencyObject dragSource, object data, System.Windows.DragDropEffects allowedEffects);
[<System.Security.SecurityCritical>]
static member DoDragDrop : System.Windows.DependencyObject * obj * System.Windows.DragDropEffects -> System.Windows.DragDropEffects
static member DoDragDrop : System.Windows.DependencyObject * obj * System.Windows.DragDropEffects -> System.Windows.DragDropEffects
Public Shared Function DoDragDrop (dragSource As DependencyObject, data As Object, allowedEffects As DragDropEffects) As DragDropEffects

매개 변수

dragSource
DependencyObject

끌어서 놓을 데이터의 소스인 종속성 개체에 대한 참조입니다.

data
Object

끌어서 놓을 데이터가 들어 있는 데이터 개체입니다.

allowedEffects
DragDropEffects

끌어서 놓기 작업에 허용되는 효과를 지정하는 DragDropEffects 값 중 하나입니다.

반환

끌어서 놓기 작업 동안 수행된 마지막 효과를 지정하는 DragDropEffects 값 중 하나입니다.

특성

예외

dragSource 또는 datanull인 경우

예제

다음 예제에서는 Ellipse 요소의 MouseMove 이벤트 처리기에서 끌어서 놓기 작업을 시작하여 끌기 소스로 만드는 방법을 보여 줍니다. 전송된 데이터는 타원 속성의 문자열 표현입니다 Fill . 데이터는 메서드에 DoDragDrop 문자열로 전달되고 에 자동으로 래핑됩니다 DataObject.

private void ellipse_MouseMove(object sender, MouseEventArgs e)
{
    Ellipse ellipse = sender as Ellipse;
    if (ellipse != null && e.LeftButton == MouseButtonState.Pressed)
    {
        DragDrop.DoDragDrop( ellipse,
                             ellipse.Fill.ToString(),
                             DragDropEffects.Copy);
    }
}
Private Sub Ellipse_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseEventArgs)
    Dim ellipse = TryCast(sender, Ellipse)
    If ellipse IsNot Nothing AndAlso e.LeftButton = MouseButtonState.Pressed Then
        DragDrop.DoDragDrop(ellipse, ellipse.Fill.ToString(), DragDropEffects.Copy)
    End If
End Sub

설명

끌기가 발생 하는 시점을 확인 한 다음 끌어서 놓기 작업을 시작 하려면 애플리케이션의 담당 합니다. 일반적으로 끌 요소에 MouseDown 대해 및 MouseMove 이벤트 시퀀스가 발생하는 경우입니다. 정적 DoDragDrop 메서드를 호출하고 전송된 데이터를 전달하여 끌어서 놓기 작업을 시작합니다. 필요할 경우 DoDragDrop 메서드는 DataObject의 데이터를 자동으로 래핑합니다. 데이터 형식에 대한 컨트롤을 강화하려면 DoDragDrop 메서드에 전달하기 전에 DataObject에서 데이터를 래핑할 수 있습니다.

메서드에서 반환되는 DoDragDrop 값은 놓기 대상의 DragEventArgs.Effects 이벤트 처리기에 설정된 속성 값입니다 Drop . 반환 값이 에 대한 호출DoDragDrop에 지정된 중 allowedEffects 하나와 일치하지 않으면 끌어서 놓기 작업이 수행되지 않습니다.

적용 대상