示例#1
0
        public void DragOver(IDropInfo dropInfo)
        {
            bool isCategory = DropEventArgs.IsCategory(dropInfo.TargetItem);
            bool isProduct  = DropEventArgs.IsProduct(dropInfo.Data);

            if (!isCategory && !isProduct)
            {
                dropInfo.Effects = DragDropEffects.None;
            }
            else
            {
                if (isProduct && dropInfo.InsertPosition.HasFlag(RelativeInsertPosition.TargetItemCenter))
                {
                    var parentCategory = (dropInfo.DragInfo.VisualSource as Control)?.DataContext as CategoryVM;
                    var targetCategory = dropInfo.TargetItem as CategoryVM;
                    if (parentCategory != targetCategory)
                    {
                        dropInfo.Effects           = DragDropEffects.Move;
                        dropInfo.DropTargetAdorner = DropTargetAdorners.Highlight;
                    }
                }
                DragDrop.DefaultDropHandler.DragOver(dropInfo);
            }
        }
示例#2
0
 public bool CanStartDrag(IDragInfo dragInfo)
 {
     return(DropEventArgs.IsCategory(dragInfo.SourceItem) || DropEventArgs.IsProduct(dragInfo.SourceItem));
 }