大家好,我有一個小問題,我希望有人能幫助我 我有一個JSON的網址,讓我這樣的數據:WP7 listpicker,從JSON結合
[
{
"nom": "fofo",
"appGuid": "79fa058b-395a-438d-b66f-d751faea82e0"
},
{
"nom": "fifi",
"appGuid": "8b6bfcdb-d286-46e2-889e-0168a782323f"
},
{
"nom": "toto",
"appGuid": "65DE39E7-0130-4836-BBD3-7051574018B6"
},
{
"nom": "titi",
"appGuid": "66DE39E7-0130-4836-BBD3-7051574018B6"
}
]
我的類:
public class ListApplication
{
public string nom { get; set; }
public string appGuid { get; set; }
}
我有一個listpicker:
我要綁定只是在listpicker元素「NOM」,我試着這種方法,但沒有任何工程: 第一種方法:
WebClient visio = new WebClient();
visio.DownloadStringCompleted += new DownloadStringCompletedEventHandler(vision_DownloadStringCompleted);
visio.DownloadStringAsync(new Uri("https://......... "));
void vision_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
return;
JArray jArray = JArray.Parse(e.Result);
List<ListApplication> apps = new List<ListApplication>();
for (int i = 0; i < jArray.Count; i++)
{
JObject app = (JObject)jArray[i];
apps.Add(new ListApplication { nom = (string)app["nom"], appGuid = (string)app["appGuid"] });
this.Application.ItemsSource = apps;
//
}
第二種方法:
public Appli()
{
InitializeComponent();
this.Type_info.ItemsSource = Action;
this.Periode.ItemsSource = Per;
var w = new WebClient();
Observable.FromEvent<DownloadStringCompletedEventArgs>(w, "DownloadStringCompleted").Subscribe(r =>
{
var deserialized =
JsonConvert.DeserializeObject<List<ListApplication>>(r.EventArgs.Result);
Application.ItemsSource = deserialized;
});
w.DownloadStringAsync(
new Uri("https://........"));
}
然後我加入的ItemSource = {結合NOM}在listpicker在XAML
任何幫助我會很感激,併爲我的英語感到抱歉
什麼確切的問題用這個?你有沒有得到錯誤或沒有得到預期的結果? – 2012-08-07 09:02:20