DragDrop.DragOver 연결된 이벤트

정의

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

see AddDragOverHandler, and RemoveDragOverHandler
see AddDragOverHandler, and RemoveDragOverHandler
see AddDragOverHandler, and RemoveDragOverHandler

예제

다음 예제에서는 Ellipse 요소에 대한 DragOver 이벤트 처리기를 보여 줍니다. 이 코드는 타원 위로 끄는 DataObjectBrush로 변환될 수 있는 문자열 데이터가 포함되어 있는지 확인합니다. 이 경우 DragEventArgs.Effects 속성을 Copy로 설정합니다. 이는 데이터를 타원에 복사할 수 있음을 끌기 소스에 나타냅니다. 데이터를 Brush로 변환할 수 없는 경우 DragEventArgs.Effects 속성이 None으로 설정됩니다. 이는 타원이 데이터에 유효한 놓기 대상이 아님을 끌기 소스에 나타냅니다.

private void ellipse_DragOver(object sender, DragEventArgs e)
{
    e.Effects = DragDropEffects.None;

    // 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, allow copying.
        BrushConverter converter = new BrushConverter();
        if (converter.IsValid(dataString))
        {
            e.Effects = DragDropEffects.Copy | DragDropEffects.Move;
        }
    }
}
Private Sub Ellipse_DragOver(ByVal sender As System.Object, ByVal e As System.Windows.DragEventArgs)
    e.Effects = DragDropEffects.None

    ' 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
            e.Effects = DragDropEffects.Copy Or DragDropEffects.Move
        End If
    End If
End Sub

설명

이 이벤트는 끌어서 놓기 대상 역할을 하는 요소의 범위 내에 있는 동안 지속적으로 발생합니다. 요소의 AllowDrop 속성 false이 이면 이 이벤트가 발생하지 않습니다.

이벤트는 DragOver 끌기 원본의 GiveFeedback 이벤트와 쌍을 이집니다. DragOver 이벤트 처리기에서는 일반적으로 전송된 데이터가 놓기 대상이 처리할 수 있는 형식임을 검사. 한정자 키를 누를지 여부를 검사 수 있습니다. 이는 일반적으로 사용자가 이동 또는 복사 작업을 원하는지 여부를 나타냅니다. 이러한 검사가 수행된 후 DragEventArgs.Effects 속성을 설정하여 끌기 소스에 데이터를 놓을 때의 효과를 알립니다. 끌기 소스는 이벤트 인수의 GiveFeedback 속성에서 Effects 이 정보를 수신하고 사용자에게 피드백을 제공할 적절한 커서를 설정할 수 있습니다.

라우팅 이벤트 정보

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

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

적용 대상

추가 정보