我是电话开发新手,当我将 JSON 数据绑定到 c# 中的列表框时,我得到一个空白屏幕,我的列表没有被填充,我成功地从 web 服务获得我的 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; }
}
}
}
我得到的 JSON 响应是[{"customer_read_status":"read","description":"Maecenas nec elit metus. Donec porttitor porttitor felis vitae hendrerit. Sed a interdum magna amet.\r\n","Inserted_Date":"Aug 14, 2013 at 01:22"},{....},{..}]
我的 XAML 代码如下
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,20" Width="300">
<TextBlock Text="{Binding Path=description}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>