protected async override void OnNavigatedTo(NavigationEventArgs e) { var favorites = (await UserDataHelper.GetFavorites("Favorites.json")); FavoritePlaces = new List <CityData>(); foreach (var item in favorites) { var _data = await UserDataHelper.GetFavoriteWeather(item.PlaceId); if (_data != null) { FavoritePlaces.Add(_data); } else { FavoritePlaces.Add(new CityData() { CoverImage = "ms-appx:///Assets/Weather/11.jpg", PlaceInfo = item }); } } var _Count = FavoritePlaces.Count(); switch (_Count) { case 0: NoPlaces.Visibility = Visibility.Visible; break; case 1: SavedPlacesGridView.MaxWidth = 250; break; case 2: SavedPlacesGridView.MaxWidth = 500; break; case 3: SavedPlacesGridView.MaxWidth = 750; break; case 4: SavedPlacesGridView.MaxWidth = 1000; break; case 5: SavedPlacesGridView.MaxWidth = 1250; break; case 6: SavedPlacesGridView.MaxWidth = 1500; break; case 7: SavedPlacesGridView.MaxWidth = 1750; break; case 8: SavedPlacesGridView.MaxWidth = 2000; break; case 9: SavedPlacesGridView.MaxWidth = 2250; break; case 10: SavedPlacesGridView.MaxWidth = 2500; break; } SavedPlacesGridView.ItemsSource = FavoritePlaces; }