Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

DragDrop Class

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.

System.Object
  System.Windows.DragDrop

Namespace:  System.Windows
Assembly:  PresentationCore (in PresentationCore.dll)
public static class DragDrop

The DragDrop type exposes the following members.

  NameDescription
Public methodStatic memberAddDragEnterHandlerAdds a DragEnter event handler to a specified dependency object.
Public methodStatic memberAddDragLeaveHandlerAdds a DragLeave event handler to a specified dependency object.
Public methodStatic memberAddDragOverHandlerAdds a DragOver event handler to a specified dependency object.
Public methodStatic memberAddDropHandlerAdds a Drop event handler to a specified dependency object.
Public methodStatic memberAddGiveFeedbackHandlerAdds a GiveFeedback event handler to a specified dependency object.
Public methodStatic memberAddPreviewDragEnterHandlerAdds a PreviewDragEnter event handler to a specified dependency object.
Public methodStatic memberAddPreviewDragLeaveHandlerAdds a PreviewDragLeave event handler to a specified dependency object.
Public methodStatic memberAddPreviewDragOverHandlerAdds a PreviewDragOver event handler to a specified dependency object.
Public methodStatic memberAddPreviewDropHandlerAdds a PreviewDrop event handler to a specified dependency object.
Public methodStatic memberAddPreviewGiveFeedbackHandlerAdds a PreviewGiveFeedback event handler to a specified dependency object.
Public methodStatic memberAddPreviewQueryContinueDragHandlerAdds a PreviewQueryContinueDrag event handler to a specified dependency object.
Public methodStatic memberAddQueryContinueDragHandlerAdds a QueryContinueDrag event handler to a specified dependency object.
Public methodStatic memberDoDragDropInitiates a drag-and-drop operation.
Public methodStatic memberRemoveDragEnterHandlerRemoves a DragEnter event handler from a specified dependency object.
Public methodStatic memberRemoveDragLeaveHandlerRemoves a DragLeave event handler from a specified dependency object.
Public methodStatic memberRemoveDragOverHandlerRemoves a DragOver event handler from a specified dependency object.
Public methodStatic memberRemoveDropHandlerRemoves a Drop event handler from a specified dependency object.
Public methodStatic memberRemoveGiveFeedbackHandlerRemoves a GiveFeedback event handler from a specified dependency object.
Public methodStatic memberRemovePreviewDragEnterHandlerRemoves a PreviewDragEnter event handler from a specified dependency object.
Public methodStatic memberRemovePreviewDragLeaveHandlerRemoves a PreviewDragLeave event handler from a specified dependency object.
Public methodStatic memberRemovePreviewDragOverHandlerRemoves a PreviewDragOver event handler from a specified dependency object.
Public methodStatic memberRemovePreviewDropHandlerRemoves a PreviewDrop event handler from a specified dependency object.
Public methodStatic memberRemovePreviewGiveFeedbackHandlerRemoves a PreviewGiveFeedback event handler from a specified dependency object.
Public methodStatic memberRemovePreviewQueryContinueDragHandlerRemoves a PreviewQueryContinueDrag event handler from a specified dependency object.
Public methodStatic memberRemoveQueryContinueDragHandlerRemoves a QueryContinueDrag event handler from a specified dependency object.
Top
  NameDescription
Public attached eventDragEnterOccurs when an object is dragged into the bounds of an element that is acting as a drop target.
Public attached eventDragLeaveOccurs when an object is dragged out of the bounds of an element that is acting as a drop target without being dropped.
Public attached eventDragOverOccurs continuously while an object is dragged within the bounds of an element that is acting as a drop target.
Public attached eventDropOccurs when an object is dropped within the bounds of an element that is acting as a drop target.
Public attached eventGiveFeedbackOccurs continuously while a drag-and-drop operation is in progress, and enables the drag source to give feedback to the user.
Public attached eventPreviewDragEnterOccurs when an object is dragged into the bounds of an element that is acting as a drop target.
Public attached eventPreviewDragLeaveOccurs when an object is dragged out of the bounds of an element that is acting as a drop target without being dropped.
Public attached eventPreviewDragOverOccurs continuously while an object is dragged within the bounds of an element that is acting as a drop target.
Public attached eventPreviewDropOccurs when an object is dropped within the bounds of an element that is acting as a drop target.
Public attached eventPreviewGiveFeedbackOccurs continuously while a drag-and-drop operation is in progress, and enables the drag source to give feedback to the user.
Public attached eventPreviewQueryContinueDragOccurs 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.
Public attached eventQueryContinueDragOccurs 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.
Top
  NameDescription
Public fieldStatic memberDragEnterEventIdentifies the DragEnter  attached event.
Public fieldStatic memberDragLeaveEventIdentifies the DragLeave  attached event
Public fieldStatic memberDragOverEventIdentifies the DragOver  attached event
Public fieldStatic memberDropEventIdentifies the Drop  attached event
Public fieldStatic memberGiveFeedbackEventIdentifies the GiveFeedback  attached event
Public fieldStatic memberPreviewDragEnterEventIdentifies the PreviewDragEnter  attached event
Public fieldStatic memberPreviewDragLeaveEventIdentifies the PreviewDragLeave  attached event
Public fieldStatic memberPreviewDragOverEventIdentifies the PreviewDragOver  attached event
Public fieldStatic memberPreviewDropEventIdentifies the PreviewDrop  attached event
Public fieldStatic memberPreviewGiveFeedbackEventIdentifies the PreviewGiveFeedback  attached event
Public fieldStatic memberPreviewQueryContinueDragEventIdentifies the PreviewQueryContinueDrag  attached event
Public fieldStatic memberQueryContinueDragEventIdentifies the QueryContinueDrag  attached event
Top

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.

NoteNote

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.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.