DragEventArgs DragEventArgs DragEventArgs DragEventArgs Class


Provides data for drag-and-drop events.

public : sealed class DragEventArgs : RoutedEventArgs, IDragEventArgs, IDragEventArgs2, IDragEventArgs3
public sealed class DragEventArgs : RoutedEventArgs, IDragEventArgs, IDragEventArgs2, IDragEventArgs3
Public NotInheritable Class DragEventArgs Inherits RoutedEventArgs Implements IDragEventArgs, IDragEventArgs2, IDragEventArgs3
// This class does not provide a public constructor.
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)


DragEventArgs is used as event data for these events:

The Control class has pre-wired event handlers that Control derived types can override to provide class-based handling for the drag-drop events, and these methods also use DragEventArgs as a parameter. These methods are:

The Windows Runtime implementation of drag-drop concepts permits only certain controls and input actions to initiate a drag-drop action. There is no generalized DoDragDrop method that would permit any UI element to initiate a drag-drop action. The main source of a drag-drop action is when you drag the items of a list such as GridView. For a list item drag-drop action, the Data value in event data can potentially be modified from the control-defined default data about the item. This is done by handling the DragItemsStarting event, and working with the DataPackage object that is obtained from the DragItemsStartingEventArgs.Data property in the event data.


AcceptedOperation AcceptedOperation AcceptedOperation AcceptedOperation

Gets or sets a value that specifies which operations are allowed by the originator of the drag event.

public : DataPackageOperation AcceptedOperation { get; set; }
public DataPackageOperation AcceptedOperation { get; set; }
Public ReadWrite Property AcceptedOperation As DataPackageOperation
var dataPackageOperation = dragEventArgs.acceptedOperation;
dragEventArgs.acceptedOperation = dataPackageOperation;
DataPackageOperation DataPackageOperation DataPackageOperation DataPackageOperation

A member of the DataPackageOperation enumeration that specifies which operations are allowed by the originator of the drag event.

AllowedOperations AllowedOperations AllowedOperations AllowedOperations

Gets the allowed data package operations (none, move, copy, and/or link) for the drag and drop operation.

public : DataPackageOperation AllowedOperations { get; }
public DataPackageOperation AllowedOperations { get; }
Public ReadOnly Property AllowedOperations As DataPackageOperation
var dataPackageOperation = dragEventArgs.allowedOperations;
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)


For more info about the allowed data operations, see DataPackageOperation.

This value is set in the DragStarting event handler. See the DragStartingEventArgs.AllowedOperations property.

See Also

Data Data Data Data

Gets or sets a data object (DataPackage ) that contains the data associated with the corresponding drag event. This value is not useful in all event cases; specifically, the event must be handled by a valid drop target.

public : DataPackage Data { get; set; }
public DataPackage Data { get; set; }
Public ReadWrite Property Data As DataPackage
var dataPackage = dragEventArgs.data;
dragEventArgs.data = dataPackage;
DataPackage DataPackage DataPackage DataPackage

The data object that contains data payload that is associated with the corresponding drag event.

DataView DataView DataView DataView

Gets a read-only copy of the Data object.

public : DataPackageView DataView { get; }
public DataPackageView DataView { get; }
Public ReadOnly Property DataView As DataPackageView
var dataPackageView = dragEventArgs.dataView;
DataPackageView DataPackageView DataPackageView DataPackageView

A read-only copy of the Data object.

DragUIOverride DragUIOverride DragUIOverride DragUIOverride

Gets the visual representation of the data being dragged.

public : DragUIOverride DragUIOverride { get; }
public DragUIOverride DragUIOverride { get; }
Public ReadOnly Property DragUIOverride As DragUIOverride
var draguiOverride = dragEventArgs.draguiOverride;
DragUIOverride DragUIOverride DragUIOverride DragUIOverride

The visual representation of the data being dragged. The default is null.

Handled Handled Handled Handled

Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route.

public : Platform::Boolean Handled { get; set; }
public bool Handled { get; set; }
Public ReadWrite Property Handled As bool
var bool = dragEventArgs.handled;
dragEventArgs.handled = bool;
Platform::Boolean bool bool bool

true if the event is marked handled; otherwise, false. The default value is false.


The events that use DragEventArgs for event data are routed events. Setting the value of the Handled property to true from an event handler can influence how a routed event behaves: it prevents handlers further along the route from being invoked. However, a handler that was attached by calling AddHandler with handledEventsToo is still invoked. For more info on the routed event concept, see Events and routed events overview.

See Also

Modifiers Modifiers Modifiers Modifiers

Gets a flag enumeration indicating the current state of the SHIFT, CTRL, and ALT keys, as well as the state of the mouse buttons.

public : DragDropModifiers Modifiers { get; }
public DragDropModifiers Modifiers { get; }
Public ReadOnly Property Modifiers As DragDropModifiers
var dragDropModifiers = dragEventArgs.modifiers;
DragDropModifiers DragDropModifiers DragDropModifiers DragDropModifiers

One or more members of the DragDropModifiers flag enumeration.


The effect of a drag-and-drop operation can be adjusted depending on the state of a particular key. For example, data may either be copied or moved depending on whether the CTRL or SHIFT keys are pressed during the drag-and-drop operation.

OriginalSource OriginalSource OriginalSource OriginalSource

Inherited from RoutedEventArgs


GetDeferral() GetDeferral() GetDeferral() GetDeferral()

Supports asynchronous drag-and-drop operations by creating and returning a DragOperationDeferral object.

public : DragOperationDeferral GetDeferral()
public DragOperationDeferral GetDeferral()
Public Function GetDeferral() As DragOperationDeferral
var dragOperationDeferral = dragEventArgs.getDeferral();

A deferral object that you can use to identify when the generation of the data package is complete.


The GetDeferral method allows your app to call a function during a drag-and-drop operation, so that your app can asynchronously generate the DataPackage object for the target app.

GetPosition(UIElement) GetPosition(UIElement) GetPosition(UIElement) GetPosition(UIElement)

Returns a drop point that is relative to a specified UIElement.

public : Point GetPosition(UIElement relativeTo)
public Point GetPosition(UIElement relativeTo)
Public Function GetPosition(relativeTo As UIElement) As Point
var point = dragEventArgs.getPosition(relativeTo);
UIElement UIElement UIElement UIElement

The UIElement for which to get a relative drop point.


A point in the coordinate system that is relative to the element specified in relativeTo.


For drag-drop operations involving a UI container, you typically call GetPosition using a relativeTo reference to the object that is the sender of the event. This gives the relative position within the container.

If this DragEventArgs is associated with the UIElement.Drop event, then the return value of GetPosition is the drop point.

See Also

See Also