public async void SearchStation(string p) { QueryText = p; if (string.IsNullOrEmpty(p)) { SuggestStations.Clear(); } else { p = p.ToLower(); //var newStations = await TaskEx.Run<List<Station>>(() => // { var stations = (_stationService.GetStations()).Where(x => x.Name.ToLower().StartsWith(p)).OrderBy(x => x.Sort).Take(15); if (stations.Count() < 15) { var extraStations = (_stationService.GetStations()).Where(x => x.StartsWith(p)).OrderBy(x => x.Sort).Take(15 - stations.Count()); stations = stations.Union(extraStations); } //return stations.ToList(); // }); SuggestStations.Clear(); //newStations.ForEach(x => StationList.Add(x)); foreach (var s in stations) { SuggestStations.Add(s); } //StationList = stations; } }
public SearchResultsViewModel(IStationNameService stationService) { _stationService = stationService; if (ViewModelBase.IsInDesignModeStatic) { List <Station> stationDesignList = new List <Station>(); stationDesignList.Add(new Station() { Name = "Amsterdam Centraal" }); stationDesignList.Add(new Station() { Name = "Delft" }); foreach (var l in stationDesignList) { SuggestStations.Add(l); } } }