public AddCityPage() { this.InitializeComponent(); this.navigationHelper = new NavigationHelper(this); this.NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Required; cityService = CityService.GetInstance(); userService = UserService.GetInstance(); resposeCities = new GetCityRespose(); resposeHotCities = new GetHotCityRespose(); resposeUserCity = new GetUserCityRespose(); }
public async Task<GetHotCityRespose> GetHotCityAsync() { GetHotCityRespose respose = new GetHotCityRespose(); respose = await Weather.Utils.JsonSerializeHelper.JsonDeSerializeForFileByInstalledLocationAsync<GetHotCityRespose>("Data\\HotCities.json").ConfigureAwait(false); return respose; }
protected async override void OnNavigatedTo(NavigationEventArgs e) { this.navigationHelper.OnNavigatedTo(e); // 获取用户城市数据 resposeUserCity = await userService.GetUserCityAsync(); // 获取城市 resposeCities = await cityService.GetCityAsync(); // 获取人们城市 resposeHotCities = await cityService.GetHotCityAsync(); ; // 数据绑定 page = new ViewModel.SelectCityPage(); page.Cities = resposeCities.Cities; page.HotCities = resposeHotCities.Cities; LayoutRoot.DataContext = page; }
/// <summary> /// 此部分中提供的方法只是用于使 /// NavigationHelper 可响应页面的导航方法。 /// <para> /// 应将页面特有的逻辑放入用于 /// <see cref="NavigationHelper.LoadState"/> /// 和 <see cref="NavigationHelper.SaveState"/> 的事件处理程序中。 /// 除了在会话期间保留的页面状态之外 /// LoadState 方法中还提供导航参数。 /// </para> /// </summary> /// <param name="e">提供导航方法数据和 /// 无法取消导航请求的事件处理程序。</param> protected async override void OnNavigatedTo(NavigationEventArgs e) { this.navigationHelper.OnNavigatedTo(e); resposeUserCity = await userService.GetUserCityAsync(); if (resposeUserCity == null) { isNotFirst = false; } else { isNotFirst = true; } resposeCities = await cityService.GetCityAsync(); resposeHotCities = await cityService.GetHotCityAsync(); ; page = new ViewModel.SelectCityPage(); page.Cities = resposeCities.Cities; page.HotCities = resposeHotCities.Cities; LayoutRoot.DataContext = page; HardwareButtons.BackPressed += HardwareButtons_BackPressed; }