01.
using
System;
02.
using
System.Collections.Generic;
03.
using
System.IO;
04.
using
System.Linq;
05.
using
Windows.Foundation;
06.
using
Windows.Foundation.Collections;
07.
using
Windows.UI.Xaml;
08.
using
Windows.UI.Xaml.Controls;
09.
using
Windows.UI.Xaml.Controls.Primitives;
10.
using
Windows.UI.Xaml.Data;
11.
using
Windows.UI.Xaml.Input;
12.
using
Windows.UI.Xaml.Media;
13.
using
Windows.UI.Xaml.Navigation;
14.
15.
using
Microsoft.WindowsAzure.MobileServices;
16.
using
Newtonsoft.Json;
17.
18.
19.
20.
namespace
myApp
21.
{
22.
/// <summary>
23.
/// An empty page that can be used on its own or navigated to within a Frame.
24.
/// </summary>
25.
///
26.
public
class
MyMember
27.
{
28.
public
int
Id {
get
;
set
; }
29.
30.
[JsonProperty(PropertyName =
"name"
)]
31.
public
string
Name {
get
;
set
; }
32.
33.
[JsonProperty(PropertyName =
"email"
)]
34.
public
string
Email {
get
;
set
; }
35.
}
36.
37.
public
sealed
partial
class
MainPage : Page
38.
{
39.
40.
private
MobileServiceCollection<MyMember, MyMember> items;
41.
private
IMobileServiceTable<MyMember> memberTable = App.MobileService.GetTable<MyMember>();
42.
43.
public
MainPage()
44.
{
45.
this
.InitializeComponent();
46.
}
47.
48.
private
async
void
RefreshMemberItems()
49.
{
50.
try
51.
{
52.
items = await memberTable.ToCollectionAsync();
53.
}
54.
catch
(MobileServiceInvalidOperationException e)
55.
{
56.
throw
e;
57.
}
58.
59.
myListbox.ItemsSource = items;
60.
}
61.
62.
/// <summary>
63.
/// Invoked when this page is about to be displayed in a Frame.
64.
/// </summary>
65.
/// <param name="e">Event data that describes how this page was reached. The Parameter
66.
/// property is typically used to configure the page.</param>
67.
protected
override
void
OnNavigatedTo(NavigationEventArgs e)
68.
{
69.
RefreshMemberItems();
70.
}
71.
}
72.
}