Introduction

So you also spent a lot of your time in data binding and it has become hectic for you? Do have some JSON data list and you want to bind it in your application? Well, if you need a quick solution you are at very right place, you would not take more than 10mins to bind your JSON list to your own application's list box in Windows Phone.

Where to start?


Mission 1: Must do before following



 ~ Get your JSON data (List/Array) in your application.

 If you are not familiar with it, you can follow my quick tutorial for this purpose.



~ Mind it that you have created Class for getting JSON data. "RootObject.cs" in my case.





Mission 2: Create sample data for your JSON data class



Open your WindowsPhone project in BLEND .



Now here real thing comes, you have to create sample data for the very class of JSON data. How you will create it? Let's have a closer look.



~ Create sample data for that click on the tab of Data.









~ Click on sample data drop down, and select "Create Sample Data from Class"





~ A menu will open now search you JSON data class "RootObject" in my case.







~ Select that class and you will see all sample data created.









~ Now drag and drop the collection from Data Tab to the page, it will show you sample data created according to that class.



Mission 3: Design the layout



For beautiful representation of your data design the layout accordingly, you can manage textbox, textblocks according to your will.







~ Create your own item template.

~ Use colors to make it  catchy.





Mission 4: Binding JSON data with the listbox



Its time to go back to Visual Studio,



~ I have a list of Entries, so to bind it I will use ObservableCollection of type Entry to bind it to my listbox.







~ As I have created Observable Collection, now I would iterate the JSON data using foreach loop.

~ After iteration I set my listbox's data context to that Observable Collection in which I iterated the data.









Note:
When sample data is generated DataContex is already set to sample values, don't forget to change it to Observable Collection.







~ Call JSON data either in constructor or using a button.

~ You are good to go ! Run your application and say WOW!!


















Others Languages

Criando um Binding de qualquer lista de dados JSON para sua aplicação em 10 minutos - Windows Phone (pt-BR)



Thanks for joining us again, see you next time.


See Also

Another important place to find a huge amount of Windows Phone related articles is the TechNet Wiki itself. The best entry point is Windows Phone Resources on the TechNet Wiki.