DragDrop.Drop 연결된 이벤트

정의

이 이벤트는 개체를 놓기 대상의 역할을 하는 요소 경계 내에 놓는 동안 발생합니다.

see AddDropHandler, and RemoveDropHandler
see AddDropHandler, and RemoveDropHandler
see AddDropHandler, and RemoveDropHandler

예제

다음 예제에서는 Ellipse 요소에 대한 Drop 이벤트 처리기를 보여 줍니다. 이 코드는 끌어서 놓기 작업의 효과를 적용합니다. 타원 위로 끄는 DataObjectBrush로 변환될 수 있는 문자열 데이터가 포함되어 있는지 확인합니다. 이 경우 Brush가 타원에 적용됩니다. 데이터를 Brush로 변환할 수 없는 경우 아무 작업도 수행되지 않습니다.

private void ellipse_Drop(object sender, DragEventArgs e)
{
    Ellipse ellipse = sender as Ellipse;
    if (ellipse != null)
    {
        // If the DataObject contains string data, extract it.
        if (e.Data.GetDataPresent(DataFormats.StringFormat))
        {
            string dataString = (string)e.Data.GetData(DataFormats.StringFormat);

            // If the string can be converted into a Brush, 
            // convert it and apply it to the ellipse.
            BrushConverter converter = new BrushConverter();
            if (converter.IsValid(dataString))
            {
                Brush newFill = (Brush)converter.ConvertFromString(dataString);
                ellipse.Fill = newFill;
            }
        }
    }
}
Private Sub Ellipse_Drop(ByVal sender As System.Object, ByVal e As System.Windows.DragEventArgs)
    Dim ellipse = TryCast(sender, Ellipse)
    If ellipse IsNot Nothing Then

        ' If the DataObject contains string data, extract it.
        If e.Data.GetDataPresent(DataFormats.StringFormat) Then
            Dim dataString = e.Data.GetData(DataFormats.StringFormat)

            ' If the string can be converted into a Brush, convert it.
            Dim converter As New BrushConverter()
            If converter.IsValid(dataString) Then
                Dim newFill As Brush = CType(converter.ConvertFromString(dataString), Brush)
                ellipse.Fill = newFill
            End If
        End If
    End If
End Sub

설명

개체 Drop 가 놓기 대상 역할을 하는 요소의 범위 내에서 삭제될 때 이벤트가 한 번 발생합니다. 요소의 AllowDrop 속성 false이 이면 이 이벤트가 발생하지 않습니다. 이 이벤트는 끌어서 놓기 작업을 종료합니다.

Drop 에서 전송된 된 데이터를 추출 이벤트 처리기는 DataObject 애플리케이션에 필요한 데이터의 처리를 수행 합니다. 끌어서 놓기의 효과(예: 복사 또는 이동)를 표시하려면 이벤트 처리기에서 Drop 속성을 설정합니다DragEventArgs.Effects. 이 속성의 값은 끌어서 놓기 작업을 시작한 메서드의 DoDragDrop 반환 값입니다. 반환되는 값이 에 대한 호출DoDragDrop에 지정된 값 중 allowedEffects 하나와 일치하지 않으면 끌어서 놓기 작업이 수행되지 않습니다. 속성의 DragEventArgs.Effects 초기 값은 메서드 호출 DoDragDrop 에서 지정한 것과 allowedEffects 동일합니다. 속성을 설정 DragEventArgs.Effects 하지 않으면 이 초기 값이 반환되고 이 값 중 하나가 allowedEffects 발생한 것으로 간주됩니다.

라우팅 이벤트 정보

식별자 필드 DropEvent
라우팅 전략 버블링
대리자 DragEventHandler

해당 터널링 이벤트가 PreviewDrop합니다.

적용 대상

추가 정보