Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Navigation;
  8. using Microsoft.Phone.Controls;
  9. using Microsoft.Phone.Shell;
  10. using PhoneApp5.Resources;
  11. using Newtonsoft.Json;
  12. namespace PhoneApp5
  13. {
  14. public partial class MainPage : PhoneApplicationPage
  15. {
  16. // Constructor
  17. public MainPage()
  18. {
  19. InitializeComponent();
  20.  
  21.  
  22. var definition1 = new { Name = "" };
  23.  
  24. var definition2 = new { id = "" }; //is that true? i want to pull inside the Table1
  25.  
  26.  
  27. string json1 = @"{'Name':'James'}";
  28.  
  29. string json2 = @"{
  30. 'Table1': [
  31. {
  32. 'id': 0,
  33. 'item': 'item 0'
  34. },
  35. {
  36. 'id': 1,
  37. 'item': 'item 1'
  38. }
  39. ]
  40. }";
  41.  
  42.  
  43. var example1 = JsonConvert.DeserializeAnonymousType(json1, definition1);
  44.  
  45. var example2 = JsonConvert.DeserializeAnonymousType(json2, definition2);
  46.  
  47.  
  48. MessageBox.Show(example2.id);
  49. // ??? i need to do with a long list selector
  50.  
  51.  
  52. }
  53.  
  54.  
  55. }
  56. }
  57.  
  58. public class MyClass
  59. {
  60. public string Id { get; set; }
  61. public string Item { get; set; }
  62. }
  63.  
  64. var myClassList = JsonConvert.DeserializeObject<List<MyClass>>(e.Result);
  65. longListSelector.ItemsSource = myClassList;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement