One: Create a common WP8.1 application
Two: In the solution Select Project, right click "Add NuGet App", add json.net
Three: Handle the JSON address of the clutch.
JSON format online proofreading: http://www.bejson.com/go.html?u=http://www.bejson.com/jsonviewernew/
JSON generates C # classes: http://tools.wx6.org/json2csharp/
Four: Enter the relevant code and bind to the foreground page in one piece:
Code for the background page:
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Net;usingSystem.Windows;usingSystem.Windows.Controls;usingSystem.Windows.Navigation;usingMicrosoft.Phone.Controls;usingMicrosoft.Phone.Shell;usingphoneapp1.resources;usingNewtonsoft.json;namespacephoneapp1{ Public Partial classMainpage:phoneapplicationpage {//constructor Function PublicMainPage () {InitializeComponent (); This. Loaded + =mainpage_loaded; //sample code for localizing ApplicationBar//Buildlocalizedapplicationbar (); } voidMainpage_loaded (Objectsender, RoutedEventArgs e) {WebClient WebClient=NewWebClient (); Webclient.downloadstringasync (NewUri ("http://wireless.tianya.cn/v/focusStand/rank?type=1&pageSize=100", Urikind.absolute)); Webclient.downloadstringcompleted+=webclient_downloadstringcompleted; } voidWebclient_downloadstringcompleted (Objectsender, DownloadStringCompletedEventArgs e) { varroot = jsonconvert.deserializeobject<root>(E.result); Lls. ItemsSource=Root. Data.list; } Private voidLls_selectionchanged (Objectsender, SelectionChangedEventArgs e) { if(LLS. SelectedItem! =NULL) { varList = (lls. SelectedItem asList); MessageBox.Show (list. CATEGORYID); } } }}
Code for the front page:
<!--Contentpanel-place other content here--<grid x:name="Contentpanel"grid.row="1"margin="12,0,12,0"> <phone:longlistselector x:name="lls"Selectionchanged="lls_selectionchanged"> <phone:LongListSelector.ItemTemplate> <DataTemplate> <StackPanel> <textblock text="{Binding CategoryName}"></TextBlock> </StackPanel> </DataTemplate> </phone:LongListSelector.ItemTemplate> </phone:LongListSelector> </Grid>
Complete.
Source: Http://pan.baidu.com/s/1qWM8FRQ
WP8.1 Development Note One: JSON data processing