private async void DigiTransitSearchBox_Loaded(object sender, RoutedEventArgs e) { this.IsEnabled = true; _favoritesService.FavoritesChanged += FavoritesChanged; Views.Busy.BusyChanged += BusyView_BusyChanged; if (!_favoritesInserted) { _favoritesInserted = true; _allFavorites = (await _favoritesService.GetFavoritesAsync()) .OfType <FavoritePlace>() .ToList(); int insertIndex = IsUserCurrentLocationListed ? 1 : 0; SuggestedPlaces.Insert(insertIndex, _favoritePlacesList); } }
public DigiTransitSearchBox() { this.InitializeComponent(); if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) { return; } _userCurrentLocationList.Add(new Place { Name = AppResources.SuggestBoxHeader_MyLocation, Type = ModelEnums.PlaceType.UserCurrentLocation }); SuggestedPlaces.Add(_userCurrentLocationList); //Load favorites in the Loaded handler SuggestedPlaces.Add(_addressList); SuggestedPlaces.Add(_stopList); PlacesCollection.Source = SuggestedPlaces; this.SearchBox.GotFocus += SearchBox_GotFocus; this.Loaded += DigiTransitSearchBox_Loaded; this.Unloaded += DigiTransitSearchBox_Unloaded; }