Search shows entries results

Selecting a result goes to the Entry Page
Auto-save on quit disabled
This commit is contained in:
2017-10-11 11:20:05 +02:00
committed by BONNEVILLE Geoffroy
parent 951172e36f
commit 454e074c44
5 changed files with 27 additions and 11 deletions

View File

@@ -1,5 +1,6 @@
using System;
using Windows.UI.Xaml;
using System.Linq;
using Windows.Storage.Streams;
using ModernKeePass.Common;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
@@ -112,5 +113,23 @@ namespace ModernKeePass.Pages
e.DestinationItem.Item = e.SourceItem.Item;
}
}
private void SearchBox_OnSuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
{
var viewModel = DataContext as GroupVm;
var imageUri = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx://Assets/Logo.scale-80.png"));
var results = viewModel.Entries.Skip(1).Where(e => e.Title.IndexOf(args.QueryText, StringComparison.OrdinalIgnoreCase) >= 0).Take(5);
foreach (var result in results)
{
args.Request.SearchSuggestionCollection.AppendResultSuggestion(result.Title, result.ParentGroup.Name, result.Id, imageUri, string.Empty);
}
}
private void SearchBox_OnResultSuggestionChosen(SearchBox sender, SearchBoxResultSuggestionChosenEventArgs args)
{
var viewModel = DataContext as GroupVm;
var entry = viewModel.Entries.Skip(1).FirstOrDefault(e => e.Id == args.Tag);
Frame.Navigate(typeof(EntryDetailPage), entry);
}
}
}