private async Task Cities_Lists_Add() //初始化城市列表 { cities_lists_uri = "http://apis.baidu.com/tngou/hospital/city"; //城市列表接口 try { cities_lists_json = await get_resquest.Get_Resquset_Result(new Uri(cities_lists_uri)); //网络请求拿到Json cities_lists_json = ConvertUnicodeToChinese.ConvertToChinese_Result(cities_lists_json); //内容转码 pane_listview.ItemsSource = App.cities_lists_list; //列表绑定 #region 添加外国地名在列表之前 App.cities_lists_list.Add(new Cities_Lists { province = "美洲" }); App.cities_lists_list.Add(new Cities_Lists { province = "欧洲" }); App.cities_lists_list.Add(new Cities_Lists { province = "非洲" }); App.cities_lists_list.Add(new Cities_Lists { province = "澳洲" }); App.cities_lists_list.Add(new Cities_Lists { province = "俄罗斯" }); App.cities_lists_list.Add(new Cities_Lists { province = "迪拜" }); App.cities_lists_list.Add(new Cities_Lists { province = "韩国" }); App.cities_lists_list.Add(new Cities_Lists { province = "日本" }); App.cities_lists_list.Add(new Cities_Lists { province = "泰国" }); App.cities_lists_list.Add(new Cities_Lists { province = "马来西亚" }); App.cities_lists_list.Add(new Cities_Lists { province = "新加坡" }); #endregion for (int i = 0; i < 34; i++) { cities_lists = JsonToObject.Cities_Lists_JsonConvert(cities_lists_json, i); App.cities_lists_list.Add(cities_lists); } } catch (Exception) { throw; } }
private async void pane_listview_ItemClick(object sender, ItemClickEventArgs e)//点击城市列表 { #region 初始化搜索城市游记 Cities_Lists cities_name = e.ClickedItem as Cities_Lists; App.travellists_query = cities_name.province; now_page = 1; #endregion splitview.IsPaneOpen = false; //关闭汉堡菜单 await Dispaly(0); //加载新闻内容 }
public static Cities_Lists Cities_Lists_JsonConvert(string json, int i)//获取城市列表 { Cities_Lists cities_lists = new Cities_Lists(); try { JObject jo1 = (JObject)JsonConvert.DeserializeObject(json); JArray ja1 = (JArray)jo1["tngou"]; cities_lists.province = ja1[i]["province"].ToString(); return(cities_lists); } catch (Exception) { throw; } }