DragDrop Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
-
DragDrop
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 |
Identifies the DragEnter attached event. |
DragLeaveEvent |
Identifies the DragLeave attached event. |
DragOverEvent |
Identifies the DragOver attached event. |
DropEvent |
Identifies the Drop attached event. |
GiveFeedbackEvent |
Identifies the GiveFeedback attached event. |
PreviewDragEnterEvent |
Identifies the PreviewDragEnter attached event. |
PreviewDragLeaveEvent |
Identifies the PreviewDragLeave attached event. |
PreviewDragOverEvent |
Identifies the PreviewDragOver attached event. |
PreviewDropEvent |
Identifies the PreviewDrop attached event. |
PreviewGiveFeedbackEvent |
Identifies the PreviewGiveFeedback attached event. |
PreviewQueryContinueDragEvent |
Identifies the PreviewQueryContinueDrag attached event. |
QueryContinueDragEvent |
Identifies the QueryContinueDrag attached event. |
Methods
Attached Events
DragEnter |
Occurs when an object is dragged into the bounds of an element that is acting as a drop target. |
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 |
Occurs continuously while an object is dragged within the bounds of an element that is acting as a drop target. |
Drop |
Occurs when an object is dropped within the bounds of an element that is acting as a drop target. |
GiveFeedback |
Occurs continuously while a drag-and-drop operation is in progress, and enables the drag source to give feedback to the user. |
PreviewDragEnter |
Occurs when an object is dragged into the bounds of an element that is acting as a drop target. |
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 |
Occurs continuously while an object is dragged within the bounds of an element that is acting as a drop target. |
PreviewDrop |
Occurs when an object is dropped within the bounds of an element that is acting as a drop target. |
PreviewGiveFeedback |
Occurs continuously while a drag-and-drop operation is in progress, and enables the drag source to give feedback to the user. |
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 |
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. |