Created
March 11, 2013 09:02
-
-
Save asarium/5132916 to your computer and use it in GitHub Desktop.
Sample of how to use IDragInfo.DataObject to use custom instances of IDataObject in gong-wpf-dragdrop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DataObjectSample : IDragSource | |
{ | |
public virtual void StartDrag(IDragInfo dragInfo) | |
{ | |
var itemCount = dragInfo.SourceItems.Cast<object>().Count(); | |
if (itemCount == 1) | |
{ | |
dragInfo.Data = dragInfo.SourceItems.Cast<object>().First(); | |
} | |
else if (itemCount > 1) | |
{ | |
dragInfo.Data = TypeUtilities.CreateDynamicallyTypedList(dragInfo.SourceItems); | |
} | |
dragInfo.Effects = (dragInfo.Data != null) ? | |
DragDropEffects.Copy | DragDropEffects.Move : | |
DragDropEffects.None; | |
// This instance will be used in the drag/drop operation | |
// Use a custom instance of IDataObject if there is something special needed | |
// for your drag/drop operation. | |
// This instance needs to be able to handle SetData so the framework can set | |
// the objects being transferred | |
dragInfo.DataObject = new DataObject(); | |
} | |
public virtual void Dropped(IDropInfo dropInfo) | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment