DragDrop.DoDragDrop Method (DependencyObject, Object, DragDropEffects)
Initiates a drag-and-drop operation.
Assembly: PresentationCore (in PresentationCore.dll)
[SecurityCriticalAttribute] public static DragDropEffects DoDragDrop( DependencyObject dragSource, object data, DragDropEffects allowedEffects )
A reference to the dependency object that is the source of the data being dragged.
A data object that contains the data being dragged.
It is the responsibility of your application to determine when a drag occurs, and then initiate the drag-and-drop operation. Typically, this is when a MouseDown and MouseMove sequence of events occurs over the element to be dragged. You initiate the drag-and-drop operation by calling the static method and passing the transferred data to it. The method will automatically wrap the data in a DataObject if necessary. For greater control over the data format, you can wrap the data in a DataObject before passing it to the method.
The value returned from the DragEventArgs.Effects property set in the drop target’s Drop event handler. If the return value does not match one of the allowedEffects specified in the call to , the drag-and-drop operation is not performed.method is the value of the
The following example shows how to initiate a drag-and-drop operation from the MouseMove event handler of an Ellipse element to make it a drag source. The transferred data is the string representation of the ellipse’s Fill property. The data is passed to the method as a string and is automatically wrapped in a DataObject.
Available since 3.0