DragDrop.DoDragDrop Method

Initiates a drag-and-drop operation.

Namespace: System.Windows
Assembly: PresentationCore (in presentationcore.dll)

public static DragDropEffects DoDragDrop (
	DependencyObject dragSource,
	Object data,
	DragDropEffects allowedEffects
)
public static DragDropEffects DoDragDrop (
	DependencyObject dragSource, 
	Object data, 
	DragDropEffects allowedEffects
)
public static function DoDragDrop (
	dragSource : DependencyObject, 
	data : Object, 
	allowedEffects : DragDropEffects
) : DragDropEffects
You cannot use methods in XAML.

Parameters

dragSource

A reference to the dependency object that is the source of the data being dragged.

data

A data object that contains the data being dragged.

allowedEffects

A value from the DragDropEffects enumeration specifying permitted effects of the drag-and-drop operation.

Return Value

A value from the DragDropEffects enumeration that specifies the final effect that was performed during the drag-and-drop operation.

Exception typeCondition

ArgumentNullException

Raised when dragSource or data is null.

The following example demonstrates how to use the DoDragDrop method.

Private Sub DragStarted()
    m_IsDown = False

    Dim serializedObject As String = m_OriginalElement.OuterXml
    Dim data As DataObject = New DataObject()
    data.SetData(m_MyFormat.Name, serializedObject)
    Dim effects As DragDropEffects = _
        DragDrop.DoDragDrop(MyCanvas, data, DragDropEffects.Copy Or DragDropEffects.Move)
    If effects And DragDropEffects.Move Then
        ' Remove the element.
        m_OriginalElement.ParentNode.RemoveChild(m_OriginalElement)
        m_OriginalElement = Nothing
    End If
End Sub

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show: