diff --git a/src/Avalonia.Controls.TreeDataGrid/TreeDataGrid.cs b/src/Avalonia.Controls.TreeDataGrid/TreeDataGrid.cs index 2017e707..a6483f1f 100644 --- a/src/Avalonia.Controls.TreeDataGrid/TreeDataGrid.cs +++ b/src/Avalonia.Controls.TreeDataGrid/TreeDataGrid.cs @@ -435,10 +435,10 @@ internal void RaiseRowPrepared(TreeDataGridRow row, int rowIndex) internal void RaiseRowDragStarted(PointerEventArgs trigger) { - if (_source is null || RowSelection is null) + if (!AutoDragDropRows || _source is null || RowSelection is null) return; - var allowedEffects = AutoDragDropRows && !_source.IsSorted ? + var allowedEffects = !_source.IsSorted ? DragDropEffects.Move : DragDropEffects.None; var route = BuildEventRoute(RowDragStartedEvent); @@ -596,8 +596,7 @@ private bool CalculateAutoDragDrop( [NotNullWhen(true)] out DragInfo? data, out TreeDataGridRowDropPosition position) { - if (!AutoDragDropRows || - e.Data.Get(DragInfo.DataFormat) is not DragInfo di || + if (e.Data.Get(DragInfo.DataFormat) is not DragInfo di || _source is null || _source.IsSorted || di.Source != _source) @@ -628,6 +627,9 @@ _source is null || private void OnDragOver(DragEventArgs e) { + if (!AutoDragDropRows) + return; + if (!TryGetRow(e.Source as Control, out var row)) { e.DragEffects = DragDropEffects.None; @@ -664,11 +666,17 @@ private void OnDragOver(DragEventArgs e) private void OnDragLeave(RoutedEventArgs e) { + if (!AutoDragDropRows) + return; + StopDrag(); } private void OnDrop(DragEventArgs e) { + if (!AutoDragDropRows) + return; + StopDrag(); if (!TryGetRow(e.Source as Control, out var row))