예제 #1
0
        private void AddCity(object parameter)
        {
            if (SelectedResult == null)
            {
                return;
            }

            forecastService.AddFavoriteCity(SelectedResult);
            FavoredCities = new ObservableCollection <City>(forecastService.GetFavoriteCities());
            PropertyChanged(this, new PropertyChangedEventArgs("FavoredCities"));
        }
예제 #2
0
        public MainPageViewModel()
        {
            this.forecastService = new ForecastService();
            this.forecastService.OnWeatherReady   += UpdateWeather;
            this.forecastService.OnForecastsReady += UpdateForecasts;
            this.cities   = forecastService.GetCities();
            FavoredCities = new ObservableCollection <City>(forecastService.GetFavoriteCities());
            Forecast      = new ObservableCollection <ForecastDTO>();

            GetWeatherCommand     = new RelayCommand(GetWeather);
            AddCityCommand        = new RelayCommand(AddCity);
            DeleteCityCommand     = new RelayCommand(DeleteCity);
            SelectForecastCommand = new RelayCommand(SelectForecast);

            SearchResults = new ObservableCollection <City>();
            SearchText    = "";
        }