コード例 #1
0
        private async void pane_listview_ItemClick(object sender, ItemClickEventArgs e)//点击新闻频道
        {
            #region 初始化新闻频道切换
            News_Channel news_channel = e.ClickedItem as News_Channel;
            App.news_channel_name = news_channel.name;
            App.news_title        = "";
            now_page = 1;
            #endregion

            splitview.IsPaneOpen = false; //关闭汉堡菜单
            await Dispaly(0);             //加载新闻内容
        }
コード例 #2
0
 public static News_Channel News_Channel_JsonConvert(string json, int i)//新闻频道反序列化
 {
     try
     {
         News_Channel news_channel = new News_Channel();
         JObject      jo1          = (JObject)JsonConvert.DeserializeObject(json);
         JObject      jo2          = (JObject)jo1["showapi_res_body"];
         JArray       ja1          = (JArray)jo2["channelList"];
         news_channel.name = ja1[i]["name"].ToString();
         return(news_channel);
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #3
0
        private async Task News_Channel_Add()                                                  //加载汉堡菜单中的新闻频道列表
        {
            pane_listview.ItemsSource = App.news_channel_list;                                 //将集合news_channel_list绑定新闻频道列表pane_listview
            channel_uri  = "http://apis.baidu.com/showapi_open_bus/channel_news/channel_news"; //新闻频道列表接口
            channel_json = await get_resquest.Get_Resquset_Result(new Uri(channel_uri));       //网络请求拿到新闻频道的Json

            channel_json = ConvertUnicodeToChinese.ConvertToChinese_Result(channel_json);      //内容转码
            try
            {
                all_channel_num = JsonToObject.All_News_Channel_Num(channel_json);
                for (int i = 0; i < all_channel_num; i++)
                {
                    news_channel = JsonToObject.News_Channel_JsonConvert(channel_json, i);
                    App.news_channel_list.Add(news_channel);
                }
            }

            catch (Exception)
            {
                throw;
            }
        }