Sunday, January 5, 2014

Drag and Drop in WPF

It is known as general practice of data transfer or location change of a particular object in specific environment.
In technical, we can say that it is a complete process of dragging an object or control from a source to target object using mouse and drop it on the desired user interface. It is a similar to copy and paste process.
Drag and drop process involves three object as sources, target and temporary storage. Source object is the source of origin from where the object is originated to drop on the target object. DataObject is used the store data temporarily.
The drag source initiates a drag-and-drop operation by calling a static DragDrop.DodragDrop method and passing the transferred data to it.The DoDragdrop method will automatically wrap the data in a DataObject if required. The drop target is responsible for extracting the data from the DataObject.   

DragDrop Effect:
While doing DragDrop process, there are many effects that can be processed on transferred data.
In WPF, there is a DragDropEffects enumeration to specify the effect of drag-drop operation. We can define effects on source as well as target.
DragDrop Event:
Drag-Drop process supports an event driven model. Both sources and target uses a specific set of event. There are events like as GiveFeedBack and QueryContinueDrag for dragging and DragEnter, DragLeave, DragOver and Drop for dropping to process drag-drop operations.
Notes:
 1.The data that is actually being transferred typically does not have a visual representation.
2.We can write code to provide a visual representation of the data that is dragged,
3. By default, feedback is provided to the user by changing the cursor to represent the effect         that the drag-and-drop operation will have on the data, such as whether the data will be           moved or copied.
 4.The DragDropEffects values are only used to provide communication between the drag source and the       drop target regarding the effects of the drag-and-drop operation.

No comments:

Copyright © Codingnodes,2014.All Rights Reserved.