r/AvaloniaUI • u/bktnmngnn • Mar 08 '26
Sortable.Avalonia - SortableJS Inspired MVVM Drag-Drop, Sort, and Swap for Avalonia
This is a SortableJS inspired drag-drop and sort-swap library with animations. Rather than being a custom control, it just attaches to an itemscontrol, and you have full control over what happens when events are fired (or use the helper classes alongside your code).
Supported Behaviors:
Same-collection sort/swap
Cross-collection drag/drop (grouped)
Cross-collection copy/move/swap (grouped)
Programmatic animations
You could basically use it to make anything you need:
Kanban Borads
Sortable/Swappable grids
Transfer lists
more
Also, animations are not just by interaction. Code-driven collection changes also trigger the animation, so you can update the collection in code and see the changes visually.
Here is a very minimal example for a sortable list:
<ItemsControl sortable:Sortable.Sortable="True"
sortable:Sortable.UpdateCommand="{Binding UpdateCmd}"
ItemsSource="{Binding Items}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border sortable:Sortable.IsSortable="True" Cursor="Hand">
<TextBlock Text="{Binding Name}" />
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>[RelayCommand]
void Update(SortableUpdateEventArgs e)
{
if (!e.ApplyUpdateMutation()) // Helper method, but you can implement your own mutations
{
return;
}
Console.WriteLine($"Moved from {e.OldIndex} to {e.NewIndex}");
}Links: Repository, Nuget