/// <summary> /// Fill week weather view with the weather data /// </summary> /// /// <param name="place">Place for which is forecast</param> async Task FillWeekWeather(string place) { XmlSerializer serializer = new XmlSerializer(typeof(WeatherData)); string xml; try { xml = await GetWeather(WeekWeatherUrl, place, 8); } catch (HttpRequestException) { throw; } if (xml != null) { try { TextReader reader = new StringReader(xml); WeatherData forecast = (WeatherData)serializer.Deserialize(reader); WeekWeather.Update(forecast); reader.Dispose(); } catch (InvalidOperationException) { throw; } } }
public MainWindow() { InitializeComponent(); Forecaster = new Forecaster(); CurrentWeather = new CurrentWeather(); DayWeather = new DayWeather(); WeekWeather = new WeekWeather(); this.CurrentPage.DataContext = CurrentWeather; this.WeekForecastPage.DataContext = DayWeather; CreateDayForecast(); this.WeekForecastPage.DataContext = WeekWeather; CreateWeekForecast(); FillWeatherPages("London"); PlaceBox.Items.Add(new TextBlock() { Text = "London" }); }