protected static bool CanAcceptData(DropInfo dropInfo) { if (dropInfo.DragInfo == null) { return(false); } if (dropInfo.DragInfo.SourceCollection == dropInfo.TargetCollection) { return(DefaultDropHandler.GetList(dropInfo.TargetCollection) != null); } else if (dropInfo.DragInfo.SourceCollection is ItemCollection) { return(false); } else { if (DefaultDropHandler.TestCompatibleTypes(dropInfo.TargetCollection, dropInfo.Data)) { return(!DefaultDropHandler.IsChildOf(dropInfo.VisualTargetItem, dropInfo.DragInfo.VisualSourceItem)); } else { return(false); } } }
public virtual void Drop(DropInfo dropInfo) { int insertIndex = dropInfo.InsertIndex; IList destinationList = DefaultDropHandler.GetList(dropInfo.TargetCollection); IEnumerable data = DefaultDropHandler.ExtractData(dropInfo.Data); if (dropInfo.DragInfo.VisualSource == dropInfo.VisualTarget) { IList sourceList = DefaultDropHandler.GetList(dropInfo.DragInfo.SourceCollection); foreach (object o in data) { int index = sourceList.IndexOf(o); if (index != -1) { sourceList.RemoveAt(index); if (sourceList == destinationList && index < insertIndex) { --insertIndex; } } } } foreach (object o in data) { destinationList.Insert(insertIndex++, o); } }