You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
844 B
32 lines
844 B
using Avalonia.Controls.Primitives; |
|
using Avalonia.Input; |
|
using StabilityMatrix.Avalonia.ViewModels; |
|
|
|
namespace StabilityMatrix.Avalonia.Controls; |
|
|
|
public abstract class DropTargetTemplatedControlBase : TemplatedControl |
|
{ |
|
protected DropTargetTemplatedControlBase() |
|
{ |
|
AddHandler(DragDrop.DropEvent, DropHandler); |
|
AddHandler(DragDrop.DragOverEvent, DragOverHandler); |
|
|
|
DragDrop.SetAllowDrop(this, true); |
|
} |
|
|
|
protected virtual void DragOverHandler(object? sender, DragEventArgs e) |
|
{ |
|
if (DataContext is IDropTarget dropTarget) |
|
{ |
|
dropTarget.DragOver(sender, e); |
|
} |
|
} |
|
|
|
protected virtual void DropHandler(object? sender, DragEventArgs e) |
|
{ |
|
if (DataContext is IDropTarget dropTarget) |
|
{ |
|
dropTarget.Drop(sender, e); |
|
} |
|
} |
|
}
|
|
|