Skip to main content

Activating Drag and Drop

  • 2 minutes to read

The Drag and Drop functionality is provided by Drag and Drop Managers specially designed for each type of View:

View Type Drag and Drop Manager Assembly
TableView GridDragDropManager DevExpress.Xpf.Grid.v14.2.Extensions
TreeListView TreeListDragDropManager DevExpress.Xpf.Grid.v14.2.Extensions

To activate Drag and Drop, do the following:

  1. Add a reference to System.Windows.Interactivity.dll and specify the corresponding namespace in XAML.

    
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
    
  2. Add the appropriateDrag and Drop Manager to the grid's Interaction.Behaviors collection.

    
    <dxg:GridControl>
    
        <dxg:GridControl.View>
            <dxg:TableView />
        </dxg:GridControl.View>
    
         <i:Interaction.Behaviors>
             <dxg:GridDragDropManager />
         </i:Interaction.Behaviors>
    
    </dxg:GridControl>
    
  3. Customize the Drag and Drop Manager. Use the following properties to provide the required behavior:

    Property Description
    AllowDrag Specifies whether rows/nodes can be dragged within a View.
    AllowDrop Specifies whether rows/nodes can be dropped within a View.
    AllowScrolling Specifies whether dragging rows/nodes to the edges of the View automatically activates scrolling.
    ScrollSpeed Specifies the scrolling speed (rows per 100 ms).
    ScrollSpacing Specifies the interval from the upper and lower edges of the View in which scrolling activates (in pixels).
  4. In some instances, you might be required to manually control drag and drop operations. To do this, handle the corresponding event(s):

    Event Description
    StartDrag Occurs before a drag operation is started. You can handle this event, for instance, to prevent dragging.
    DragOver Occurs repeatedly when a drag operation is in process. This event enables you to control whether a row/node can be dropped at the current location.
    Drop Occurs after a drag and drop operation has been completed.

#Examples