Skip to content

Instantly share code, notes, and snippets.

@asarium
Created March 11, 2013 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asarium/5132916 to your computer and use it in GitHub Desktop.
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.
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