diff --git a/src/Avalonia.Base/Input/DragDrop.cs b/src/Avalonia.Base/Input/DragDrop.cs index fe75f678e1..0bb4450e66 100644 --- a/src/Avalonia.Base/Input/DragDrop.cs +++ b/src/Avalonia.Base/Input/DragDrop.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using Avalonia.Input.Platform; using Avalonia.Interactivity; @@ -41,6 +42,86 @@ namespace Avalonia.Input interactive.SetValue(AllowDropProperty, value); } + /// + /// Adds a handler for the DragEnter attached event. + /// + /// The element to attach the handler to. + /// The handler for the event. + public static void AddDragEnterHandler(Interactive element, EventHandler handler) + { + element.AddHandler(DragEnterEvent, handler); + } + + /// + /// Removes a handler for the DragEnter attached event. + /// + /// The element to remove the handler from. + /// The handler to remove. + public static void RemoveDragEnterHandler(Interactive element, EventHandler handler) + { + element.RemoveHandler(DragEnterEvent, handler); + } + + /// + /// Adds a handler for the DragLeave attached event. + /// + /// The element to attach the handler to. + /// The handler for the event. + public static void AddDragLeaveHandler(Interactive element, EventHandler handler) + { + element.AddHandler(DragLeaveEvent, handler); + } + + /// + /// Removes a handler for the DragLeave attached event. + /// + /// The element to remove the handler from. + /// The handler to remove. + public static void RemoveDragLeaveHandler(Interactive element, EventHandler handler) + { + element.RemoveHandler(DragLeaveEvent, handler); + } + + /// + /// Adds a handler for the DragOver attached event. + /// + /// The element to attach the handler to. + /// The handler for the event. + public static void AddDragOverHandler(Interactive element, EventHandler handler) + { + element.AddHandler(DragOverEvent, handler); + } + + /// + /// Removes a handler for the DragOver attached event. + /// + /// The element to remove the handler from. + /// The handler to remove. + public static void RemoveDragOverHandler(Interactive element, EventHandler handler) + { + element.RemoveHandler(DragOverEvent, handler); + } + + /// + /// Adds a handler for the Drop attached event. + /// + /// The element to attach the handler to. + /// The handler for the event. + public static void AddDropHandler(Interactive element, EventHandler handler) + { + element.AddHandler(DropEvent, handler); + } + + /// + /// Removes a handler for the Drop attached event. + /// + /// The element to remove the handler from. + /// The handler to remove. + public static void RemoveDropHandler(Interactive element, EventHandler handler) + { + element.RemoveHandler(DropEvent, handler); + } + /// /// Starts a dragging operation with the given and returns the applied drop effect from the target. ///