mirror of
https://github.com/AtomUI/AtomUI.git
synced 2026-10-27 12:17:42 +08:00
Optimize DataGrid column reorder
Added support for synchronous scrolling of the horizontal scroll bar when dragging and sorting columns
This commit is contained in:
@@ -374,9 +374,10 @@ internal partial class DataGridColumnHeader : ContentControl
|
||||
internal void HandleMouseLeftButtonUp(ref bool handled, PointerEventArgs args, Point mousePosition, Point mousePositionHeaders)
|
||||
{
|
||||
IsPressed = false;
|
||||
|
||||
|
||||
if (OwningGrid != null && OwningGrid.ColumnHeaders != null)
|
||||
{
|
||||
var horizontalOffset = OwningGrid.HorizontalScrollBar?.Value ?? mousePosition.X;
|
||||
if (HeaderDragMode == DragMode.MouseDown)
|
||||
{
|
||||
HandleMouseLeftButtonUpClick(args.KeyModifiers, ref handled);
|
||||
@@ -390,9 +391,10 @@ internal partial class DataGridColumnHeader : ContentControl
|
||||
|| (OwningColumn.IsFrozen && targetIndex < OwningGrid.LeftFrozenColumnCount)))
|
||||
{
|
||||
OwningColumn.DisplayIndex = targetIndex;
|
||||
|
||||
DataGridColumnEventArgs ea = new DataGridColumnEventArgs(OwningColumn);
|
||||
OwningGrid.NotifyColumnReordered(ea);
|
||||
OwningGrid.ScrollIntoView(null, _dragColumn);
|
||||
OwningGrid.UpdateHorizontalOffset(horizontalOffset);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -523,7 +523,7 @@ public partial class DataGrid
|
||||
// The row is already displayed in its entirety
|
||||
return true;
|
||||
}
|
||||
else if (DisplayData.FirstScrollingSlot == slot && slot != -1)
|
||||
if (DisplayData.FirstScrollingSlot == slot && slot != -1)
|
||||
{
|
||||
if (!MathUtilities.IsZero(NegVerticalOffset))
|
||||
{
|
||||
@@ -611,8 +611,7 @@ public partial class DataGrid
|
||||
// We scrolled too far because a row's height was larger than its approximation
|
||||
_verticalOffset = NegVerticalOffset;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Debug.Assert(MathUtilities.LessThanOrClose(NegVerticalOffset, _verticalOffset));
|
||||
|
||||
SetVerticalOffset(_verticalOffset);
|
||||
|
||||
Reference in New Issue
Block a user