Skip to content

Commit a21e412

Browse files
authored
Fix: Fixed an issue where opening new columns in Columns View didn't always scroll them into view (#17826)
1 parent b77b6ff commit a21e412

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Files.App.Controls/BladeView/BladeView.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,17 @@ private ScrollViewer GetScrollViewer()
150150
return _scrollViewer ?? (_scrollViewer = this.FindDescendant<ScrollViewer>());
151151
}
152152

153+
public void ScrollToEnd()
154+
{
155+
LayoutUpdated += OnLayoutUpdatedScrollToEnd;
156+
}
157+
158+
private void OnLayoutUpdatedScrollToEnd(object sender, object e)
159+
{
160+
LayoutUpdated -= OnLayoutUpdatedScrollToEnd;
161+
GetScrollViewer()?.ChangeView(_scrollViewer.ScrollableWidth, null, null, false);
162+
}
163+
153164
private void AdjustBladeItemSize()
154165
{
155166
// Adjust blade items to be full screen
@@ -182,7 +193,8 @@ private void ItemsVectorChanged(IObservableVector<object> sender, IVectorChanged
182193
else if (e.CollectionChange == CollectionChange.ItemInserted)
183194
{
184195
UpdateLayout();
185-
GetScrollViewer()?.ChangeView(_scrollViewer.ScrollableWidth, null, null);
196+
// The following line doesn't work as expected due to the items not being fully loaded yet and thus the scrollable width not being accurate.
197+
//GetScrollViewer()?.ChangeView(_scrollViewer.ScrollableWidth, null, null);
186198
}
187199
}
188200
}

src/Files.App/Views/Layouts/ColumnsLayoutPage.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ public void SetWidth(int index)
8989

9090
var blade = activeBlades[index];
9191
blade?.SetWidth();
92+
93+
ColumnHost.ScrollToEnd();
9294
}
9395

9496
private void ContentChanged(IShellPage p)

0 commit comments

Comments
 (0)