DragnDrop 1.0.0

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package DragnDrop --version 1.0.0
                    
NuGet\Install-Package DragnDrop -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DragnDrop" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DragnDrop" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="DragnDrop" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DragnDrop --version 1.0.0
                    
#r "nuget: DragnDrop, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DragnDrop@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DragnDrop&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=DragnDrop&version=1.0.0
                    
Install as a Cake Tool

Avalonia Dragging Service

A lightweight, cross-platform drag-and-drop interaction service for AvaloniaUI, designed for flexibility and extensibility.
Supports multiple independent or nested instances, complex drop precedence, and custom drag/drop logic via callbacks.

Compatible with Avalonia 11+ and .NET 8.0+


✨ Features

  • Multiple independent instances within the same visual tree
  • Nested instance support with inner precedence resolution
  • Overlap-aware drop target and dragged control resolution, prioritizing deeper controls
  • Custom drag/drop callbacks via attached properties (AllowDrag, AllowDrop)
  • Pointer-aware drag context: includes full PointerEventArgs and dragged control set
  • Dynamic service management via IDisposable pattern
  • XAML/Binding-ready: Easy to integrate via attached properties
  • Cross-platform: Fully compatible with all Avalonia-supported platforms

🛠️ How to Use

1. Mark a container (that inherits from Panel control) as the root of a drag instance

<StackPanel local:DraggingServiceAttached.IsRootOfDraggingInstance="True">

2. Enable Dragging/Dropping on your controls:

<Button Content="Drag me!"
        local:DraggingServiceAttached.AllowDrag="{Binding OnDragCallback}" />
<TextBlock Content="Drop on me!"
        local:DraggingServiceAttached.AllowDrag="{Binding OnDropCallback}" />

3. Implement the callbacks in your ViewModel (better for an MVVM approach) or code-behind:

void OnDragCallback(DraggingServiceCallbackArgs args) {
    // Access dragged controls and pointer info
    var controls = args.DraggedControls;
    var pointer = args.PointerEvent;
    // Logic here
}

void OnDropCallback(DraggingServiceCallbackArgs args) {
    // Access dragged controls and pointer info
    var controls = args.DraggedControls;
    var pointer = args.PointerEvent;
    // Logic here
}

Data can be read via the data-context of the dragged controls/drop targets for a better MVVM approach

4. Dispose the service when no longer needed by setting IsRootOfDraggingInstance property to false on the root control:

    control.SetValue(IsRootOfDraggingInstance, false)

or

    DraggingServiceAttached.SetIsRootOfDraggingInstance(control, false);
Notes:
  • The service sets a transparent Background if not present and enables the IsHitTestVisible property for every control used in the service.
  • Calling Dispose() on the actual instance will not work. Always set the IsRootOfDraggingInstance Attached Property to dispose the instance.
  • Each attached property can be set via XAML or code-behind, allowing for flexible integration.
Roadmap and improvements 🚧:
  • Add support for multiple dragged controls at the same time
  • Add options to tunneling or bubbling events for overlapped dragged controls or drop targets
  • Add support for dynamic visual tree changes
  • Add support for async callbacks
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated