private void TextChanged(object sender, TextChangedEventArgs args) { var text = tb.Text; var filterResults = new WindowFilterer().Filter(_windowList, text).ToList(); foreach (var filterResult in filterResults) { filterResult.AppWindow.FormattedTitle = GetFormattedTitleFromBestResult(filterResult.WindowTitleMatchResults); filterResult.AppWindow.FormattedProcessTitle = GetFormattedTitleFromBestResult(filterResult.ProcessTitleMatchResults); } lb.DataContext = filterResults.Select(r => r.AppWindow); if (lb.Items.Count > 0) { lb.SelectedItem = lb.Items[0]; } }
private void TextChanged(object sender, TextChangedEventArgs args) { var query = tb.Text; var context = new WindowFilterContext<AppWindowViewModel> { Windows = _unfilteredWindowList, ForegroundWindowProcessTitle = new AppWindow(_foregroundWindow.HWnd).ProcessTitle }; var filterResults = new WindowFilterer().Filter(context, query).ToList(); foreach (var filterResult in filterResults) { filterResult.AppWindow.FormattedTitle = GetFormattedTitleFromBestResult(filterResult.WindowTitleMatchResults); filterResult.AppWindow.FormattedProcessTitle = GetFormattedTitleFromBestResult(filterResult.ProcessTitleMatchResults); } _filteredWindowList = new ObservableCollection<AppWindowViewModel>(filterResults.Select(r => r.AppWindow)); lb.DataContext = _filteredWindowList; if (lb.Items.Count > 0) { lb.SelectedItem = lb.Items[0]; } }