using Avalonia.Input; using StabilityMatrix.Avalonia.ViewModels; namespace StabilityMatrix.Avalonia.Controls; public abstract class DropTargetUserControlBase : UserControlBase { protected DropTargetUserControlBase() { AddHandler(DragDrop.DropEvent, DropHandler); AddHandler(DragDrop.DragOverEvent, DragOverHandler); DragDrop.SetAllowDrop(this, true); } private void DragOverHandler(object? sender, DragEventArgs e) { if (DataContext is IDropTarget dropTarget) { dropTarget.DragOver(sender, e); } } private void DropHandler(object? sender, DragEventArgs e) { if (DataContext is IDropTarget dropTarget) { dropTarget.Drop(sender, e); } } }