C# 无法将JSON数据绑定到windows phone 8中的列表
我是手机开发新手,当我将JSON数据绑定到c#中的列表框时,我得到一个空白屏幕,我的列表没有填充,我成功地从web服务获得JSON响应,我的代码如下C# 无法将JSON数据绑定到windows phone 8中的列表,c#,xaml,windows-phone-7,data-binding,windows-phone-8,C#,Xaml,Windows Phone 7,Data Binding,Windows Phone 8,我是手机开发新手,当我将JSON数据绑定到c#中的列表框时,我得到一个空白屏幕,我的列表没有填充,我成功地从web服务获得JSON响应,我的代码如下 public void callbackwall(object sender, UploadStringCompletedEventArgs e) { string json = e.Result.ToString(); if (!string.IsNullOrEmpty(json)) {
public void callbackwall(object sender, UploadStringCompletedEventArgs e)
{
string json = e.Result.ToString();
if (!string.IsNullOrEmpty(json))
{
var example = JsonConvert.DeserializeObject<List<listreadqueries>>(json);
ServerList.ItemsSource = example;
}
}
public class readqueriesObject
{
public string customer_read_status { get; set; }
public string description { get; set; }
public string Inserted_Date { get; set; }
public string Query_From_Id { get; set; }
public string Query_From_Name { get; set; }
public string Query_Id { get; set; }
public string Query_Status { get; set; }
public string Query_To_Id { get; set; }
public string Query_To_Name { get; set; }
public string title { get; set; }
public int count { get; set; }
public List<object> historyList { get; set; }
public string Query_Type { get; set; }
}
public class listreadqueries
{
public List<readqueriesObject> queries { get; set; }
}
}
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,20" Width="300">
<TextBlock Text="{Binding Path=description}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
您的反序列化应该是
var example = JsonConvert.DeserializeObject<List<readqueriesObject>>(json);
var-example=JsonConvert.DeserializeObject(json);
无需listreadquerys
PS:json是一个数组,而不是包含对象的数组({querys:[…]}
)