wpf-119260-controls-and-libraries-data-grid-drag-and-drop-process-drag-and-drop-drag-and-drop-between-gridcontrol-and-other-controls.md
The GridControl allows dragging records and dropping them in external controls. This topic demonstrates how to implement drag-and-drop between the GridControl and other controls that do not have a built-in drag-and-drop functionality.
The following image shows dragging records to and from the custom TextBlock :
View Example: How to implement drag-and-drop between the GridControl and other controls
Add the GridControl to your project’s window:
Add the TextBlock to your project’s window. The code sample below demonstrates the TextBlock with custom settings:
Set the DataViewBase.AllowDragDrop property to true to enable drag-and-drop in the GridControl :
Set the UIElement.AllowDrop property to true to allow dropping records in the TextBlock.
Process dropped data and specify the TextBlock ‘s content:
You can add actions that are performed during dragging. Use the DragDrop.DragEnter and DragDrop.DragLeave events on the TextBlock to indicate a drop target. The code sample below demonstrates how to change the TextBlock’s background color when dragging records into/out of the TextBlock:
The TextBlock can be a drag source. Complete the following tasks to initiate a drag-and-drop operation:
Now you can drag data from the TextBlock but not drop it in the GridControl. Perform the following steps to allow dropping:
Complete the following actions to process dropped data:
See Also
Drag-and-Drop Between GridControl and ListBoxEdit