DragDrop DragDrop DragDrop DragDrop Class

Definition

Provides helper methods and fields for initiating drag-and-drop operations, including a method to begin a drag-and-drop operation, and facilities for adding and removing drag-and-drop related event handlers.

public ref class DragDrop abstract sealed
public static class DragDrop
type DragDrop = class
Public Class DragDrop
Inheritance
DragDropDragDropDragDropDragDrop

Remarks

Drag-and-drop commonly refers to a method of data transfer that involves using a mouse (or some other pointing device) to select one or more objects, dragging these objects over some desired drop target in the user interface (UI), and dropping them. A drag-and-drop operation is analogous to a copy (or cut)-and-paste operation that is used to transfer data from one object or application to another. Drag-and-drop operations typically involve two parties: a drag source from which the dragged data originates and a drop target which receives the dropped data. The events and methods required for drag-and-drop operations are defined in the DragDrop class. The drag-and-drop events are attached events that can be attached to any UIElement or ContentElement. The drag source and drop target may be UI elements in the same application or in different applications. However, the drop target must know how to process the data being passed by the drag source.

Note

The UIElement and ContentElement classes contain aliases for the drag-and-drop events so that the events appear in the class members list when these classes are inherited as a base class. When you attach an event handler to a drag-and-drop event on one of these classes, the handler is attached to the underlying DragDrop event and they receive the same instance of event data. For example, see UIElement.Drop.

The drag source initiates a drag-and-drop operation by calling the static DoDragDrop method and passing the transferred data to it. An element typically handles the following events when it is a drag source:

An element typically handles the following events when it is a drop target:

For more information and examples, see Drag and Drop Overview.

Fields

DragEnterEvent DragEnterEvent DragEnterEvent DragEnterEvent

Identifies the DragEnter attached event.

DragLeaveEvent DragLeaveEvent DragLeaveEvent DragLeaveEvent

Identifies the DragLeave attached event

DragOverEvent DragOverEvent DragOverEvent DragOverEvent

Identifies the DragOver attached event

DropEvent DropEvent DropEvent DropEvent

Identifies the Drop attached event

GiveFeedbackEvent GiveFeedbackEvent GiveFeedbackEvent GiveFeedbackEvent

Identifies the GiveFeedback attached event

PreviewDragEnterEvent PreviewDragEnterEvent PreviewDragEnterEvent PreviewDragEnterEvent

Identifies the PreviewDragEnter attached event

PreviewDragLeaveEvent PreviewDragLeaveEvent PreviewDragLeaveEvent PreviewDragLeaveEvent

Identifies the PreviewDragLeave attached event

PreviewDragOverEvent PreviewDragOverEvent PreviewDragOverEvent PreviewDragOverEvent

Identifies the PreviewDragOver attached event

PreviewDropEvent PreviewDropEvent PreviewDropEvent PreviewDropEvent

Identifies the PreviewDrop attached event

PreviewGiveFeedbackEvent PreviewGiveFeedbackEvent PreviewGiveFeedbackEvent PreviewGiveFeedbackEvent

Identifies the PreviewGiveFeedback attached event

PreviewQueryContinueDragEvent PreviewQueryContinueDragEvent PreviewQueryContinueDragEvent PreviewQueryContinueDragEvent

Identifies the PreviewQueryContinueDrag attached event

QueryContinueDragEvent QueryContinueDragEvent QueryContinueDragEvent QueryContinueDragEvent

Identifies the QueryContinueDrag attached event

Methods

AddDragEnterHandler(DependencyObject, DragEventHandler) AddDragEnterHandler(DependencyObject, DragEventHandler) AddDragEnterHandler(DependencyObject, DragEventHandler) AddDragEnterHandler(DependencyObject, DragEventHandler)

Adds a DragEnter event handler to a specified dependency object.

AddDragLeaveHandler(DependencyObject, DragEventHandler) AddDragLeaveHandler(DependencyObject, DragEventHandler) AddDragLeaveHandler(DependencyObject, DragEventHandler) AddDragLeaveHandler(DependencyObject, DragEventHandler)

Adds a DragLeave event handler to a specified dependency object.

AddDragOverHandler(DependencyObject, DragEventHandler) AddDragOverHandler(DependencyObject, DragEventHandler) AddDragOverHandler(DependencyObject, DragEventHandler) AddDragOverHandler(DependencyObject, DragEventHandler)

Adds a DragOver event handler to a specified dependency object.

AddDropHandler(DependencyObject, DragEventHandler) AddDropHandler(DependencyObject, DragEventHandler) AddDropHandler(DependencyObject, DragEventHandler) AddDropHandler(DependencyObject, DragEventHandler)

Adds a Drop event handler to a specified dependency object.

AddGiveFeedbackHandler(DependencyObject, GiveFeedbackEventHandler) AddGiveFeedbackHandler(DependencyObject, GiveFeedbackEventHandler) AddGiveFeedbackHandler(DependencyObject, GiveFeedbackEventHandler) AddGiveFeedbackHandler(DependencyObject, GiveFeedbackEventHandler)

Adds a GiveFeedback event handler to a specified dependency object.

AddPreviewDragEnterHandler(DependencyObject, DragEventHandler) AddPreviewDragEnterHandler(DependencyObject, DragEventHandler) AddPreviewDragEnterHandler(DependencyObject, DragEventHandler) AddPreviewDragEnterHandler(DependencyObject, DragEventHandler)

Adds a PreviewDragEnter event handler to a specified dependency object.

AddPreviewDragLeaveHandler(DependencyObject, DragEventHandler) AddPreviewDragLeaveHandler(DependencyObject, DragEventHandler) AddPreviewDragLeaveHandler(DependencyObject, DragEventHandler) AddPreviewDragLeaveHandler(DependencyObject, DragEventHandler)

Adds a PreviewDragLeave event handler to a specified dependency object.

AddPreviewDragOverHandler(DependencyObject, DragEventHandler) AddPreviewDragOverHandler(DependencyObject, DragEventHandler) AddPreviewDragOverHandler(DependencyObject, DragEventHandler) AddPreviewDragOverHandler(DependencyObject, DragEventHandler)

Adds a PreviewDragOver event handler to a specified dependency object.

AddPreviewDropHandler(DependencyObject, DragEventHandler) AddPreviewDropHandler(DependencyObject, DragEventHandler) AddPreviewDropHandler(DependencyObject, DragEventHandler) AddPreviewDropHandler(DependencyObject, DragEventHandler)

Adds a PreviewDrop event handler to a specified dependency object.

AddPreviewGiveFeedbackHandler(DependencyObject, GiveFeedbackEventHandler) AddPreviewGiveFeedbackHandler(DependencyObject, GiveFeedbackEventHandler) AddPreviewGiveFeedbackHandler(DependencyObject, GiveFeedbackEventHandler) AddPreviewGiveFeedbackHandler(DependencyObject, GiveFeedbackEventHandler)

Adds a PreviewGiveFeedback event handler to a specified dependency object.

AddPreviewQueryContinueDragHandler(DependencyObject, QueryContinueDragEventHandler) AddPreviewQueryContinueDragHandler(DependencyObject, QueryContinueDragEventHandler) AddPreviewQueryContinueDragHandler(DependencyObject, QueryContinueDragEventHandler) AddPreviewQueryContinueDragHandler(DependencyObject, QueryContinueDragEventHandler)

Adds a PreviewQueryContinueDrag event handler to a specified dependency object.

AddQueryContinueDragHandler(DependencyObject, QueryContinueDragEventHandler) AddQueryContinueDragHandler(DependencyObject, QueryContinueDragEventHandler) AddQueryContinueDragHandler(DependencyObject, QueryContinueDragEventHandler) AddQueryContinueDragHandler(DependencyObject, QueryContinueDragEventHandler)

Adds a QueryContinueDrag event handler to a specified dependency object.

DoDragDrop(DependencyObject, Object, DragDropEffects) DoDragDrop(DependencyObject, Object, DragDropEffects) DoDragDrop(DependencyObject, Object, DragDropEffects) DoDragDrop(DependencyObject, Object, DragDropEffects)

Initiates a drag-and-drop operation.

RemoveDragEnterHandler(DependencyObject, DragEventHandler) RemoveDragEnterHandler(DependencyObject, DragEventHandler) RemoveDragEnterHandler(DependencyObject, DragEventHandler) RemoveDragEnterHandler(DependencyObject, DragEventHandler)

Removes a DragEnter event handler from a specified dependency object.

RemoveDragLeaveHandler(DependencyObject, DragEventHandler) RemoveDragLeaveHandler(DependencyObject, DragEventHandler) RemoveDragLeaveHandler(DependencyObject, DragEventHandler) RemoveDragLeaveHandler(DependencyObject, DragEventHandler)

Removes a DragLeave event handler from a specified dependency object.

RemoveDragOverHandler(DependencyObject, DragEventHandler) RemoveDragOverHandler(DependencyObject, DragEventHandler) RemoveDragOverHandler(DependencyObject, DragEventHandler) RemoveDragOverHandler(DependencyObject, DragEventHandler)

Removes a DragOver event handler from a specified dependency object.

RemoveDropHandler(DependencyObject, DragEventHandler) RemoveDropHandler(DependencyObject, DragEventHandler) RemoveDropHandler(DependencyObject, DragEventHandler) RemoveDropHandler(DependencyObject, DragEventHandler)

Removes a Drop event handler from a specified dependency object.

RemoveGiveFeedbackHandler(DependencyObject, GiveFeedbackEventHandler) RemoveGiveFeedbackHandler(DependencyObject, GiveFeedbackEventHandler) RemoveGiveFeedbackHandler(DependencyObject, GiveFeedbackEventHandler) RemoveGiveFeedbackHandler(DependencyObject, GiveFeedbackEventHandler)

Removes a GiveFeedback event handler from a specified dependency object.

RemovePreviewDragEnterHandler(DependencyObject, DragEventHandler) RemovePreviewDragEnterHandler(DependencyObject, DragEventHandler) RemovePreviewDragEnterHandler(DependencyObject, DragEventHandler) RemovePreviewDragEnterHandler(DependencyObject, DragEventHandler)

Removes a PreviewDragEnter event handler from a specified dependency object.

RemovePreviewDragLeaveHandler(DependencyObject, DragEventHandler) RemovePreviewDragLeaveHandler(DependencyObject, DragEventHandler) RemovePreviewDragLeaveHandler(DependencyObject, DragEventHandler) RemovePreviewDragLeaveHandler(DependencyObject, DragEventHandler)

Removes a PreviewDragLeave event handler from a specified dependency object.

RemovePreviewDragOverHandler(DependencyObject, DragEventHandler) RemovePreviewDragOverHandler(DependencyObject, DragEventHandler) RemovePreviewDragOverHandler(DependencyObject, DragEventHandler) RemovePreviewDragOverHandler(DependencyObject, DragEventHandler)

Removes a PreviewDragOver event handler from a specified dependency object.

RemovePreviewDropHandler(DependencyObject, DragEventHandler) RemovePreviewDropHandler(DependencyObject, DragEventHandler) RemovePreviewDropHandler(DependencyObject, DragEventHandler) RemovePreviewDropHandler(DependencyObject, DragEventHandler)

Removes a PreviewDrop event handler from a specified dependency object.

RemovePreviewGiveFeedbackHandler(DependencyObject, GiveFeedbackEventHandler) RemovePreviewGiveFeedbackHandler(DependencyObject, GiveFeedbackEventHandler) RemovePreviewGiveFeedbackHandler(DependencyObject, GiveFeedbackEventHandler) RemovePreviewGiveFeedbackHandler(DependencyObject, GiveFeedbackEventHandler)

Removes a PreviewGiveFeedback event handler from a specified dependency object.

RemovePreviewQueryContinueDragHandler(DependencyObject, QueryContinueDragEventHandler) RemovePreviewQueryContinueDragHandler(DependencyObject, QueryContinueDragEventHandler) RemovePreviewQueryContinueDragHandler(DependencyObject, QueryContinueDragEventHandler) RemovePreviewQueryContinueDragHandler(DependencyObject, QueryContinueDragEventHandler)

Removes a PreviewQueryContinueDrag event handler from a specified dependency object.

RemoveQueryContinueDragHandler(DependencyObject, QueryContinueDragEventHandler) RemoveQueryContinueDragHandler(DependencyObject, QueryContinueDragEventHandler) RemoveQueryContinueDragHandler(DependencyObject, QueryContinueDragEventHandler) RemoveQueryContinueDragHandler(DependencyObject, QueryContinueDragEventHandler)

Removes a QueryContinueDrag event handler from a specified dependency object.

Attached Events

DragEnter DragEnter DragEnter DragEnter

Occurs when an object is dragged into the bounds of an element that is acting as a drop target.

DragLeave DragLeave DragLeave DragLeave

Occurs when an object is dragged out of the bounds of an element that is acting as a drop target without being dropped.

DragOver DragOver DragOver DragOver

Occurs continuously while an object is dragged within the bounds of an element that is acting as a drop target.

Drop Drop Drop Drop

Occurs when an object is dropped within the bounds of an element that is acting as a drop target.

GiveFeedback GiveFeedback GiveFeedback GiveFeedback

Occurs continuously while a drag-and-drop operation is in progress, and enables the drag source to give feedback to the user.

PreviewDragEnter PreviewDragEnter PreviewDragEnter PreviewDragEnter

Occurs when an object is dragged into the bounds of an element that is acting as a drop target.

PreviewDragLeave PreviewDragLeave PreviewDragLeave PreviewDragLeave

Occurs when an object is dragged out of the bounds of an element that is acting as a drop target without being dropped.

PreviewDragOver PreviewDragOver PreviewDragOver PreviewDragOver

Occurs continuously while an object is dragged within the bounds of an element that is acting as a drop target.

PreviewDrop PreviewDrop PreviewDrop PreviewDrop

Occurs when an object is dropped within the bounds of an element that is acting as a drop target.

PreviewGiveFeedback PreviewGiveFeedback PreviewGiveFeedback PreviewGiveFeedback

Occurs continuously while a drag-and-drop operation is in progress, and enables the drag source to give feedback to the user.

PreviewQueryContinueDrag PreviewQueryContinueDrag PreviewQueryContinueDrag PreviewQueryContinueDrag

Occurs continuously while a drag-and-drop operation is in progress, and enables the drop source to end the drag-and-drop operation depending on the key/button states.

QueryContinueDrag QueryContinueDrag QueryContinueDrag QueryContinueDrag

Occurs continuously while a drag-and-drop operation is in progress, and enables the drop source to end the drag-and-drop operation depending on the key/button states.

Applies to

See Also