다음을 통해 공유


DragDrop.Drop 연결된 이벤트

정의

개체가 놓기 대상 역할을 하는 요소의 범위 내에서 삭제될 때 발생합니다.

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

예제

다음 예제에서는 요소에 Drop 대한 이벤트 처리기를 보여 있습니다 Ellipse . 이 코드는 끌어서 놓기 작업의 효과를 적용합니다. 줄임표 위로 끌 때 변환Brush할 수 있는 문자열 데이터가 포함되어 있는지 DataObject 확인합니다. 이 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 발생한 것으로 간주됩니다.

라우트된 이벤트 정보

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

해당 터널링 이벤트는 PreviewDrop.

적용 대상

추가 정보