TreeDataGrid supports row drag/drop with automatic data movement and event hooks.
<TreeDataGrid Source="{Binding Source}" AutoDragDropRows="True" />
With this enabled, grid can perform internal move operations when allowed.
RowDragStartedRowDragOverRowDropAttach in XAML or code-behind.
<TreeDataGrid
AutoDragDropRows="True"
RowDragStarted="DragDrop_RowDragStarted"
RowDragOver="DragDrop_RowDragOver" />
TreeDataGridRowDragStartedEventArgs:
Models: dragged model setAllowedEffects: set to permit/deny effectsTreeDataGridRowDragEventArgs:
TargetRow: row being hovered/droppedPosition: None, Before, After, InsideInner: underlying DragEventArgsExample from sample pattern:
private void DragDrop_RowDragStarted(object? sender, TreeDataGridRowDragStartedEventArgs e)
{
foreach (DragDropItem i in e.Models)
{
if (!i.AllowDrag)
e.AllowedEffects = DragDropEffects.None;
}
}
private void DragDrop_RowDragOver(object? sender, TreeDataGridRowDragEventArgs e)
{
if (e.Position == TreeDataGridRowDropPosition.Inside &&
e.TargetRow?.Model is DragDropItem i &&
!i.AllowDrop)
e.Inner.DragEffects = DragDropEffects.None;
}
Automatic move operation is blocked when:
MoveIList<T>Flat source supports Before / After.
Hierarchical source supports Before / After / Inside.
Before: insert before target rowAfter: insert after target rowInside: insert as child of target row (hierarchical only)Grid shows drag adorner and supports auto-scroll near edges while dragging.
Feature behavior differs from expectations
Cause: one or more options in this scenario are configured differently (source type, column options, sort/selection/edit state).
Fix: compare your setup with the snippet in this article and verify runtime values on Source, Columns, and Selection.
Data changes are not visible in UI
Cause: model or collection notifications are missing, or a replaced collection/source is not re-bound.
Fix: ensure INotifyPropertyChanged/INotifyCollectionChanged flow is active and reassign Source after replacing underlying collections.