/// <summary> /// Event handler to handle when this page is navigated to /// </summary> protected override void OnNavigatedTo(NavigationEventArgs e) { // get the city, latitude, and longitude out of the query string string cityName = this.NavigationContext.QueryString["City"]; string latitude = this.NavigationContext.QueryString["Latitude"]; string longitude = this.NavigationContext.QueryString["Longitude"]; forecast = new Forecast(); // get the forecast for the given latitude and longitude forecast.GetForecast(latitude, longitude); // set data context for page to this forecast DataContext = forecast; // set source for ForecastList box in page to our list of forecast time periods ForecastList.ItemsSource = forecast.ForecastList; }
private void Button_Click(object sender, RoutedEventArgs e) { var data = new List <Forecast>(); int days = (int)_days.SelectedItem; var rnd = new Random(); for (int i = 0; i < days; i++) { double temp = rnd.NextDouble() * 40 - 10; var forecast = new Forecast { GeneralForecast = (GeneralForecast)rnd.Next( Enum.GetValues(typeof(GeneralForecast)).Length), TemperatureLow = temp, TemperatureHigh = temp + rnd.NextDouble() * 15, Percipitation = rnd.Next(10) > 5 ? rnd.NextDouble() * 10 : 0 }; data.Add(forecast); } DataContext = data; }
public Task SaveData(Forecast forecast) { return(Task.CompletedTask); }