diff --git a/Happy Reader/View/Tabs/DatabaseTab.xaml.cs b/Happy Reader/View/Tabs/DatabaseTab.xaml.cs index e9925ef..3e911eb 100644 --- a/Happy Reader/View/Tabs/DatabaseTab.xaml.cs +++ b/Happy Reader/View/Tabs/DatabaseTab.xaml.cs @@ -61,6 +61,7 @@ private void OnLoaded(object sender, RoutedEventArgs e) if (_loaded) return; if (DesignerProperties.GetIsInDesignMode(this)) return; ViewModel = (DatabaseViewModelBase)DataContext; + ViewModel.ScrollToTop = ScrollToTop; _loaded = true; } @@ -184,5 +185,12 @@ private void OpenVNPanel(MouseEventArgs e, FrameworkElement element, bool switch if (vn == null) return; StaticMethods.MainWindow.OpenVNPanel(vn, switchToTab); } + + private void ScrollToTop() + { + var firstItem = VisualNovelItems.Items[0]; + if(firstItem == null) return; + VisualNovelItems.ScrollIntoView(firstItem); + } } } diff --git a/Happy Reader/ViewModel/DatabaseViewModelBase.cs b/Happy Reader/ViewModel/DatabaseViewModelBase.cs index 7d7b0a6..24f809d 100644 --- a/Happy Reader/ViewModel/DatabaseViewModelBase.cs +++ b/Happy Reader/ViewModel/DatabaseViewModelBase.cs @@ -106,6 +106,7 @@ public SuggestionScorer SuggestionScorer } } public TitleOrderingType OrderingType { get; private set; } + public Action ScrollToTop { get; set; } protected DatabaseViewModelBase(MainWindowViewModel mainWindowViewModel) { @@ -210,8 +211,8 @@ protected async Task RefreshTiles() OnPropertyChanged(nameof(CSettings)); OnPropertyChanged(nameof(Tiles)); OnPropertyChanged(nameof(AllResults)); - - }); + ScrollToTop?.Invoke(); + }); watch.Stop(); SetReplyText($"Loaded results in {watch.Elapsed.ToSeconds()}.", VndbConnection.MessageSeverity.Normal);