reset scrollviewer on page change (#8742)

This commit is contained in:
Davide Giacometti
2021-01-05 16:01:42 +01:00
committed by GitHub
parent b590437ca1
commit 4958f6c158
2 changed files with 11 additions and 4 deletions

View File

@@ -27,7 +27,8 @@
IsSettingsVisible="False"
OpenPaneLength="296"
CompactModeThresholdWidth="0"
Background="{ThemeResource SystemControlBackgroundAltHighBrush}">
Background="{ThemeResource SystemControlBackgroundAltHighBrush}"
SelectionChanged="NavigationView_SelectionChanged">
<winui:NavigationView.MenuItems>
<winui:NavigationViewItem x:Uid="Shell_General" helpers:NavHelper.NavigateTo="views:GeneralPage" AutomationProperties.HeadingLevel="Level1">
<winui:NavigationViewItem.Icon>
@@ -103,7 +104,8 @@
<ic:InvokeCommandAction Command="{x:Bind ViewModel.ItemInvokedCommand}" />
</ic:EventTriggerBehavior>
</i:Interaction.Behaviors>
<ScrollViewer Grid.Column="0">
<ScrollViewer x:Name="scrollViewer"
Grid.Column="0">
<Grid Margin="{StaticResource MediumLeftRightBottomMargin}">
<Frame x:Name="shellFrame" />
</Grid>

View File

@@ -2,9 +2,8 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using Microsoft.PowerToys.Settings.UI.Library;
using System.Diagnostics.CodeAnalysis;
using Microsoft.PowerToys.Settings.UI.ViewModels;
using Windows.Data.Json;
using Windows.UI.Xaml.Controls;
@@ -129,5 +128,11 @@ namespace Microsoft.PowerToys.Settings.UI.Views
{
shellFrame.Navigate(typeof(GeneralPage));
}
[SuppressMessage("Usage", "CA1801:Review unused parameters", Justification = "Params are required for event handler signature requirements.")]
private void NavigationView_SelectionChanged(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewSelectionChangedEventArgs args)
{
scrollViewer.ChangeView(null, 0, null, true);
}
}
}