private void SearchBox_TextChanged(object sender, TextChangedEventArgs e) { var keyword = SearchBox.Text.Trim(); if (string.IsNullOrEmpty(keyword)) { UpdateList(); } else { var query = EntryQuery.GetListByKeyword(keyword, _entries); UpdateView(query); } }
private async Task PlayListQueryAsync() { if (App.Beatmaps == null) { return; } //SortEnum sortEnum = (SortEnum)cbSortType.SelectedItem; SortMode sortMode = SortMode.Artist; _querySw.Restart(); if (_queryLock) { return; } _queryLock = true; await Task.Run(() => { while (_querySw.ElapsedMilliseconds < 300) { Thread.Sleep(1); } _querySw.Stop(); _queryLock = false; string keyword = null; Dispatcher.Invoke(() => { keyword = SearchBox.Text.Trim(); }); var sorted = string.IsNullOrEmpty(keyword) ? App.Beatmaps.SortBy(sortMode).Transform(false) : EntryQuery.GetListByKeyword(keyword, App.Beatmaps).SortBy(sortMode).Transform(false); Dispatcher.BeginInvoke(new Action(() => { ResultList.DataContext = sorted; })); }); }