Skip to content

Commit

Permalink
reset scrollviewer on page change (#8742)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidegiacometti committed Jan 5, 2021
1 parent b590437 commit 4958f6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -129,5 +128,11 @@ public void Refresh()
{
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);
}
}
}

0 comments on commit 4958f6c

Please sign in to comment.