WP8.1 Development Note One: JSON data processing

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.