if (_selectedDateViewModel == null)
{
_selectedDateViewModel = new SelectedDateViewModel();
- // I always receive my parameter even if page was tombstoned. :)
- string stringIndex = NavigationContext.QueryString["parameter"];
- _selectedDateViewModel.SelectedDateIndex = Convert.ToInt32(stringIndex, CultureInfo.InvariantCulture);
}
DataContext = _selectedDateViewModel;
// and it has remained in memory, this value will continue to be false.
_isNewPageInstance = false;
- UpdateApplicationDataUI();
+ // I always receive my parameter even if page was tombstoned. :)
+ string stringIndex = NavigationContext.QueryString["parameter"];
+ int index = Convert.ToInt32(stringIndex, CultureInfo.InvariantCulture);
+
+ UpdateApplicationDataUI(index);
}
- void UpdateApplicationDataUI()
+ void UpdateApplicationDataUI(int index)
{
WeatherData weatherData = (Application.Current as WeatherInformation.App).ApplicationDataObject;
if (weatherData != null)
{
- _selectedDateViewModel.LoadData(weatherData);
+ _selectedDateViewModel.LoadData(weatherData, index);
}
}
}
{
private readonly SettingsViewModel _settings = new SettingsViewModel();
- [DataMember]
- public Int32 SelectedDateIndex { get; set; }
public String TitleTextCityCountry { get; private set; }
public String SelectedDatePressure { get; private set; }
public String SelectedDatePressureUnits { get; private set; }
- public void LoadData(WeatherData weatherData)
+ public void LoadData(WeatherData weatherData, int index)
{
var remoteForecastWeatherData = weatherData.RemoteForecast;
- WeatherInformation.Model.ForecastWeatherParser.List forecast = remoteForecastWeatherData.list[this.SelectedDateIndex];
+ WeatherInformation.Model.ForecastWeatherParser.List forecast = remoteForecastWeatherData.list[index];
DateTime unixTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
DateTime date = unixTime.AddSeconds(forecast.dt).ToLocalTime();
this.SelectedDate = date.ToString("m", CultureInfo.InvariantCulture);