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 |
---|---|---|
Table |
Grid |
DevExpress. |
Tree |
Tree |
DevExpress. |
To activate Drag and Drop, do the following:
Add a reference to System.Windows.Interactivity.dll and specify the corresponding namespace in XAML.
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
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>
Customize the Drag and Drop Manager. Use the following properties to provide the required behavior:
Property Description Allow Drag Specifies whether rows/nodes can be dragged within a View. Allow Drop Specifies whether rows/nodes can be dropped within a View. Allow Scrolling Specifies whether dragging rows/nodes to the edges of the View automatically activates scrolling. Scroll Speed Specifies the scrolling speed (rows per 100 ms). Scroll Spacing Specifies the interval from the upper and lower edges of the View in which scrolling activates (in pixels). In some instances, you might be required to manually control drag and drop operations. To do this, handle the corresponding event(s):
Event Description Start Drag Occurs before a drag operation is started. You can handle this event, for instance, to prevent dragging. Drag Over 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.