DragEventArgs DragEventArgs DragEventArgs Class

Provides data for drag-and-drop events.

Syntax

Declaration

public sealed class DragEventArgspublic sealed class DragEventArgsPublic NotInheritable Class DragEventArgs

Inheritance Hierarchy

Remarks

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 Data property in the event data.

Properties summary

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

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

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.

Gets a read-only copy of the Data object.

Gets the visual representation of the data being dragged.

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

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

Methods summary

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

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

Properties

  • 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

    Property Value

  • 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

    Property Value

    Remarks

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

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

  • 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

    Property Value

  • 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

    Property Value

  • 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

    Property Value

  • 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 bool Handled { get; set; }public bool Handled { get; set; }Public ReadWrite Property Handled As bool

    Property Value

    • bool
      bool
      bool

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

    Remarks

    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(Windows.UI.Xaml.RoutedEvent,System.Object,System.Boolean) with handledEventsToo is still invoked. For more info on the routed event concept, see Events and routed events overview.

  • 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

    Property Value

    Remarks

    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.

Methods

  • 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

    Returns

    Remarks

    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(Windows.UI.Xaml.UIElement)
    GetPosition(Windows.UI.Xaml.UIElement)
    GetPosition(Windows.UI.Xaml.UIElement)
    GetPosition(Windows.UI.Xaml.UIElement)

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

    public Point GetPosition(Windows.UI.Xaml.UIElement)public Point GetPosition(Windows.UI.Xaml.UIElement)Public Function GetPosition(Windows.UI.Xaml.UIElement) As Point

    Parameters

    Returns

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

    Remarks

    For drag-drop operations involving a UI container, you typically call GetPosition(Windows.UI.Xaml.UIElement) 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 Drop event, then the return value of GetPosition(Windows.UI.Xaml.UIElement) is the drop point.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.WebHostHiddenAttribute

Details

Assembly

Windows.UI.Xaml.dll