From f5f898d64c2677e04d014297899108b4c533b3a5 Mon Sep 17 00:00:00 2001 From: DE-YU Date: Mon, 22 Apr 2024 16:57:18 +0800 Subject: [PATCH] Fix scroll Bar is not accurately reflecting the virtual viewport position. --- GDViews.VirtualGridView/Core/VirtualGridViewImpl.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/GDViews.VirtualGridView/Core/VirtualGridViewImpl.cs b/GDViews.VirtualGridView/Core/VirtualGridViewImpl.cs index b074c8e..e5707fb 100644 --- a/GDViews.VirtualGridView/Core/VirtualGridViewImpl.cs +++ b/GDViews.VirtualGridView/Core/VirtualGridViewImpl.cs @@ -42,7 +42,6 @@ internal class VirtualGridViewImpl : private NullableData _currentSelectedData; private int _currentSelectedViewColumnIndex; - private int _currentSelectedViewRowIndex; private DataView[,] _currentView; @@ -797,9 +796,10 @@ private void UpdateScrollBar(int dataRows, int dataColumns, bool noAnimation = f } else { - rowProgress = ViewRowIndex / (float)(dataRows - ViewRows); + var fixedDataRows = (float)dataRows; + rowProgress = ViewRowIndex / fixedDataRows; rowProgress = Math.Max(rowProgress, 0f); - rowPage = ViewRows / (float)dataRows; + rowPage = ViewRows / fixedDataRows; canAutoHideRowScrollBar = false; } @@ -811,9 +811,10 @@ private void UpdateScrollBar(int dataRows, int dataColumns, bool noAnimation = f } else { - columnProgress = ViewColumnIndex / (float)(dataColumns - ViewColumns); + var fixedDataColumns = (float)dataColumns; + columnProgress = ViewColumnIndex / fixedDataColumns; columnProgress = Math.Max(columnProgress, 0f); - columnPage = ViewColumns / (float)dataColumns; + columnPage = ViewColumns / fixedDataColumns; canAutoHideColumnScrollBar = false; }