public void Search() { if (_lookup == null) { return; } if (!_lookup.Any()) { return; } var searchItem = txtSearch.Text; if (searchItem.Trim().Length == 0) { RefreshDisplay(); } else { var filteredItem = from item in _lookup where item.CollectorName.ToLower().Contains(searchItem.ToLower()) select item; var viewModel = new CollectorViewModel { Collection = new CollectorCollection() }; foreach (var item in filteredItem) { viewModel.Collection.Add(item); } _viewModel = viewModel; DataContext = _viewModel; } }
public void RefreshDisplay() { _lookup = Collector.CollectAll(); _viewModel = new CollectorViewModel { Collection = Collector.CollectAll() }; DataContext = _viewModel; }