DragDropExample
. For more information, see Walkthrough: My first WPF desktop application.Circle.xaml
, and click Add.dragSource
– A reference to this control.data
– The DataObject created in the previous code.allowedEffects
– The allowed drag-and-drop operations, which are Copy or Move.green
from the TextBox.green
text to a Circle control. Notice that the default cursors are shown to indicate the effects of the drag-and-drop operation. The feedback cursor is always set by the drag source.true
.true
and data from the drag source is dropped on the Circle user control. In this method, you will process the data that was dropped and apply the data to the Circle.green
in the TextBox.green
in the TextBox.gre
in the TextBox.gre
is not a valid color.true
and processing the dropped data is all that is required to enable an element to be a drop target. However, to provide a better user experience, you should also handle the DragEnter, DragLeave, and DragOver events. In these events, you can perform checks and provide additional feedback to the user before the data is dropped.gre
in the TextBox.gre
is not a valid color._previousFill
and initialize it to null
._previousFill
variable._previousFill
variable to the Fill of the Ellipse that provides the UI of the Circle user control.green
in the TextBox.panel_DragOver
, and name the Drop event handler, panel_Drop
.green
from the TextBox.