void DropItemBehavior::OnDragLeave(BaseComponent* sender, const DragEventArgs& e) { ContentControl* control = (ContentControl*)sender; Slot* slot = (Slot*)control->GetContent(); slot->SetIsDragOver(false); e.handled = true; }
void DropItemBehavior::OnDrop(BaseComponent*, const DragEventArgs& e) { ContentControl* control = GetAssociatedObject(); Slot* sourceSlot = (Slot*)e.data; Slot* targetSlot = (Slot*)control->GetContent(); targetSlot->SetIsDragOver(false); if (targetSlot->GetIsDropAllowed()) { // Move any item in target slot to the source slot sourceSlot->SetItem(targetSlot->GetItem()); // Move dragged item to the target slot targetSlot->SetItem(ViewModel::Instance()->GetDraggedItem()); } else { e.effects = DragDropEffects_None; } e.handled = true; }