Skip to content

Commit

Permalink
Navigate to Playlist when filtering tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
sabihoshi committed May 30, 2021
1 parent 2b5adac commit 2af27d6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion GenshinLyreMidiPlayer.WPF/GenshinLyreMidiPlayer.WPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<UseWPF>true</UseWPF>
<StartupObject>GenshinLyreMidiPlayer.WPF.App</StartupObject>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Version>2.1.0.1</Version>
<Version>2.2.0</Version>
<ApplicationIcon>item_windsong_lyre.ico</ApplicationIcon>
<Nullable>enable</Nullable>
<RepositoryUrl>https://github.com/sabihoshi/GenshinLyreMidiPlayer</RepositoryUrl>
Expand Down
18 changes: 16 additions & 2 deletions GenshinLyreMidiPlayer.WPF/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using GenshinLyreMidiPlayer.Data;
using GenshinLyreMidiPlayer.WPF.Views;
using ModernWpf;
using ModernWpf.Controls;
using Stylet;
using StyletIoC;
Expand Down Expand Up @@ -41,7 +42,7 @@ protected override async void OnViewLoaded()
// Work around because events do not conform to the signatures Stylet supports
_navView = ((MainWindowView) View).NavView;

_navView.AutoSuggestBox.TextChanged += PlaylistView.OnFilterTextChanged;
_navView.AutoSuggestBox.TextChanged += AutoSuggestBoxOnTextChanged;

_navView.SelectionChanged += Navigate;
_navView.BackRequested += NavigateBack;
Expand All @@ -59,6 +60,19 @@ protected override async void OnViewLoaded()
await PlaylistView.AddFiles(db.History.Select(midi => midi.Path));
}

private void AutoSuggestBoxOnTextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs e)
{
PlaylistView.OnFilterTextChanged(sender, e);
if (ActiveItem != PlaylistView)
{
var playlist = (NavigationViewItem) _navView.MenuItems
.Cast<NavigationViewItemBase>()
.First(nav => nav.Tag == PlaylistView);

_navView.SelectedItem = playlist;
}
}

private void NavigateBack(NavigationView sender, NavigationViewBackRequestedEventArgs args)
{
GoBack();
Expand Down

0 comments on commit 2af27d6

Please sign in to comment.