diff --git a/ViewModels/NotesViewModel.cs b/ViewModels/NotesViewModel.cs index 89a3508..9a0b80b 100644 --- a/ViewModels/NotesViewModel.cs +++ b/ViewModels/NotesViewModel.cs @@ -109,20 +109,22 @@ public async Task OnDisappearing() public void SearchForNotes(object? sender, EventArgs eventArgs) { - // SearchBar searchBar = (SearchBar)sender; - // var searchKeyword = searchBar.Text; - // - // if (searchKeyword == string.Empty) - // { - // Notes = AllNotes; - // return; - // } - // - // Notes = AllNotes.FindAll(n => - // { - // var keyword = $"{n.location}/{n.name}"; - // return keyword.Contains(searchKeyword, StringComparison.CurrentCultureIgnoreCase); - // }); + SearchBar searchBar = (SearchBar)sender; + var searchKeyword = searchBar.Text; + + if (AllNotes == null) AllNotes = Notes.ToList(); + + if (searchKeyword == string.Empty) + { + Notes = new ObservableCollection(AllNotes); + return; + } + + Notes = new ObservableCollection(AllNotes.FindAll(n => + { + var keyword = $"{n.location}/{n.name}"; + return keyword.Contains(searchKeyword, StringComparison.CurrentCultureIgnoreCase); + })); } [RelayCommand]