protected override async void OnNavigatedTo(NavigationEventArgs e) { LoadProcess.IsActive = true; var data = e.Parameter as string[]; var id = data[0]; title.Text = data[1]; var songlistdata = await SongLsitData.GetData(id); if (songlistdata != null) { SongListView.ItemsSource = songlistdata.List; SongListView.SelectionMode = ListViewSelectionMode.Single; SongListView.SelectionChanged += SongListView_SelectionChanged; } LoadProcess.IsActive = false; }
public static async Task <SongLsitData> GetData(string id) { try { var httpclient = new System.Net.Http.HttpClient(); var json = await httpclient.GetStringAsync("http://mobilecdn.kugou.com/api/v3/special/song?pagesize=-1&plat=0&page=1&version=8150&specialid=" + id); json = json.Replace("320hash", "hash320"); var obj = Windows.Data.Json.JsonObject.Parse(json); var data = new SongLsitData(); data.List = Class.data.DataContractJsonDeSerialize <ObservableCollection <SongData> >(obj.GetNamedObject("data").GetNamedArray("info").ToString()); return(data); } catch (Exception) { return(null); } }