#694 – An Example of Custom Drag-and-Drop Behavior

You can define your own drag-and-drop behavior in an application, defining the content to be dragged and the controls that the user drags the content from and to.  The basic process for drag-and-drop is:

  • User presses and holds a mouse button (typically left mouse button) on a control that contains the data to be dragged (the source element)
  • User moves mouse pointer over another control, where the data is to be dropped (the target element)
  • User releases mouse button
  • Data is “dropped” onto target control (control is typically updated to reflect new content)

In the example below, the user can select some text in the TextBox and drag it to the ListBox, adding a new item to the list for each chunk of text dragged.

Advertisements