"Pro WPF with VB 2008: Windows Presentation Foundation with .NET 3.5"
At this point you identify the source of the drag-anddrop operation, set aside the content you want to transfer, and indicate what drag-and-drop effects are allowed (copying, moving, and so on). Usually, the DoDragDrop() method is called in response to the MouseDown or Preview- MouseDown event. Here??™s an example that initiates a drag-and-drop operation when a label is clicked. The text content from the label is used for the drag-and-drop operation: Private Sub lblSource_MouseDown(ByVal sender As Object, _ ByVal e As MouseButtonEventArgs) Dim lbl As Label = CType(sender, Label) DragDrop.DoDragDrop(lbl, lbl.Content, DragDropEffects.Copy) End Sub The element that receives the data needs to set its AllowDrop property to True. Additionally, it needs to handle the Drop event to deal with the data:
When you set AllowDrop to True, you configure an element to allow any type of information. If you want to be pickier, you can handle the DragEnter event. At this point, you can check the type of data that??™s being dragged and then determine what type of operation to allow. The following example only allows text content??”if you drag something that cannot be converted to text, the drag-and-drop operation won??™t be allowed and the mouse pointer will change to the forbidding circle-with-a-line cursor: Private Sub lblTarget_DragEnter(ByVal sender As Object, _ ByVal e As DragEventArgs) If e.