FluentDragDrop 2.2.3

dotnet add package FluentDragDrop --version 2.2.3
                    
NuGet\Install-Package FluentDragDrop -Version 2.2.3
                    
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="FluentDragDrop" Version="2.2.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FluentDragDrop" Version="2.2.3" />
                    
Directory.Packages.props
<PackageReference Include="FluentDragDrop" />
                    
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 FluentDragDrop --version 2.2.3
                    
#r "nuget: FluentDragDrop, 2.2.3"
                    
#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 FluentDragDrop@2.2.3
                    
#: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=FluentDragDrop&version=2.2.3
                    
Install as a Cake Addin
#tool nuget:?package=FluentDragDrop&version=2.2.3
                    
Install as a Cake Tool

Fluent Drag&Drop

NuGet Status <sup>🔆 Now with effects</sup>

Drag&Drop in WinForms is cumbersome and error-prone. There are multiple events to handle, members to track and properties to set on at least two controls. Passing data is kind of special and you don't get preview images while dragging things around.

Wouldn't it be great if you could use Drag&Drop with fluent code like this?

<a id='snippet-immediateusage'></a>

private void picControlPreviewBehindCursor_MouseDown(object sender, MouseEventArgs e)
{
	var pic = (PictureBox)sender;

	pic.InitializeDragAndDrop()
		.Copy()
		.Immediately()
		.WithData(pic.Image)
		.WithPreview().BehindCursor()
		.To(PreviewBoxes, (target, data) => target.Image = data);

	// Copy(), Move() or Link() to define allowed effects
	// Immediately() or OnMouseMove() for deferred start on mouse move
	// WithData() to pass any object you like
	// WithPreview() to define your preview and how it should behave
	//     BehindCursor() or RelativeToCursor() to define the preview placement
	// To() to define target controls and how the dragged data should be used on drop
}

<sup><a href='/src/FluentDragDropExample/TestForm.cs#L32-L51' title='File snippet immediateusage was extracted from'>snippet source</a> | <a href='#snippet-immediateusage' title='Navigate to start of snippet immediateusage'>anchor</a></sup>

It's all in there: Putting data to the drag&drop operation, attaching a custom preview image to the mouse cursor, working with the dragged data once it's dropped and much more.

Screenshot

Did you notice that you can even update preview images and their opacity at any time while dragging? 😉

Perfect by default

In real world apps, Drag&Drop should not start at MouseDown because the control selection might not be up to date to the mouse interaction. Instead, developers typically have to keep track that MouseDown did happen and add an additional event handler to MouseMove. If MouseMove is triggered and there was a MouseDown but no MouseUp, the user pressed the mouse button and moved the mouse. So that's when he wanted to start a Drag&Drop operation.

Careful developers won't track a flag whether the mouse button is still down or not but the location where the user pressed the button. On MouseMove, they can then calculate the distance how much the cursor did move. Having a few pixels buffer here helps to prevent the user from accidential Drag&Drop operations.

FluentDrag&Drop does exactly that if defined with OnMouseMove(). However there is no flag or location to track. Methods like WithData() won't accept direct variables to be passed anymore, instead they require a function which gets called as soon as the mouse move is detected later on - if the user pressed and held the mouse button and if he moved a few pixels. Additionally, the developer has the possibility to validate the input like a valid control selection with If(). Of course, this gets called just like WithData() as soon as the user moves the mouse accordingly:

<a id='snippet-delayedusage'></a>

private void CountryList_MouseDown(object sender, MouseEventArgs e)
{
	var source = (ListView)sender;
	var target = source.Equals(listLeft) ? listRight : listLeft;

	source.InitializeDragAndDrop()
		.Move()
		.OnMouseMove()
		.If(() => source.SelectedIndices.Count > 0)
		.WithData(() => source.SelectedItems.OfType<ListViewItem>().ToArray())
		.WithPreview((_, data) => RenderPreview(data)).BehindCursor()
		.To(target, MoveItems);
}

<sup><a href='/src/FluentDragDropExample/TestForm.cs#L80-L94' title='File snippet delayedusage was extracted from'>snippet source</a> | <a href='#snippet-delayedusage' title='Navigate to start of snippet delayedusage'>anchor</a></sup>

This (<sub><sup>and the 5 line method MoveItems()</sub></sup>) is everything we need to implement two-way Drag&Drop lists:

Screenshot

Compatibility

FluentDrag&Drop can easily be used with your current Drag&Drop implementations if you want. The following animation shows how it works in combination with traditional Drag&Drop implementations as we know with events like DragEnter, DragOver and DragDrop:

Screenshot

Smoothness

Most approaches I have used in the past get in trouble when moving the preview over controls that do not have the property AllowDrop set to true. Whenever a Drag&Drop implementation uses the GiveFeedback event to update its preview images, you might get laggy Drag&Drop experiences with stuttering preview image movements.

In contrast, FluentDrag&Drop will render preview images smoothly wherever you move them, even over other applications.

🔆 Effects

To make your drag and drop implementation even more impressive, this repository also contains a project called "FluentDragDrop.Effects". It is part of the FluentDrag&Drop solution but builds to a separate and optional package which extends FluentDrag&Drop with a set of default effects.

Some of these effects are:

  • FadeIn
  • FadeOut
  • ReturnOnCancel
  • MorphToTarget

Effects

The sample above shows some of the effects in action:

  • FadeIn on start
  • ReturnOnCancel when dropping next to the empty box
  • MorphToTarget when dropping into the empty box
    • this effect is accompanied by an additional effect implemented in the sample app causing the box to fade a color

FluentTransitions

Those effects are powered by another project called FluentTransitions allowing the animations and transitions to be rendered smoothly. I'd encourage you to check it out:


Images taken from Unsplash, links to these are located at /doc/Unsplash.

Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net8.0-windows was computed.  net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed.  net10.0-windows7.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0-windows7.0

    • No dependencies.
  • net6.0-windows7.0

    • No dependencies.
  • net8.0-windows7.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on FluentDragDrop:

Package Downloads
FluentDragDrop.Effects

FluentDrag&Drop is the sexiest Drag&Drop implemtation for WinForms on this planet. This package extends FluentDrag&Drop with rich effects. Powered by FluentTransitions. The app icon was made by Freepik from www.flaticon.com and is licensed by Creative Commons BY 3.0.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.2.3 37 11/4/2026
2.2.2 44 11/4/2026
2.2.1 2,049 11/11/2025
2.2.0 1,174 5/10/2024
2.1.7 427 4/2/2024
2.1.3 1,317 5/13/2022
2.1.1 951 5/13/2022
2.0.0 923 4/29/2022
1.1.0 1,431 10/14/2020
1.0.0 1,001 10/4/2020
0.2.1 744 9/28/2020
0.2.0 714 9/28/2020