【发布时间】:2014-07-16 13:09:25
【问题描述】:
我正在使用 c# 在 windows 8.1 应用程序中填充列表视图,如下所示
dynamic obj = JsonConvert.DeserializeObject(resp);
List<Notice> items = new List<Notice>();
foreach (var o in obj)
{
Notice notice = new Notice();
items.Add(new Notice() { title = o["title"], from = o["from"] });
}
NoticeBinding.ItemsSource = items;
}
public class Notice
{
public string id { get; set; }
public string title { get; set; }
public string from { get; set; }
public string sendername { get; set; }
public string date { get; set; }
public string content { get; set; }
}
这给了我一个合适的 listView。我想处理 itemClick 事件。 JSON响应中对应的“id”有通知的“title”、“content”和“sender”。因此,一旦我单击任何列表视图项,就会显示相应的通知。以下是我的 JSON 响应的一部分
{
"id":20,
"title":"Testing after phase 2 is shifted to server",
"from":"Administrator",
"sendername":"ABX",
"day":"Tuesday",
"dateofMonth":"20th",
"month":"May",
"year":2014,
"date":"Tuesday, 20th May, 2014",
"content":"Ready. Set. Go"
}
在列表视图中仅显示“标题”和“来自”。但点击后应显示标题、内容、发件人。有什么帮助吗?
【问题讨论】:
-
那么为什么只用
title和from填充Notice?你试过用你需要的所有属性填充它吗? -
这是只显示标题名称和发件人的列表。就像电子邮件应用程序一样。所以点击通知后会显示通知的内容、发件人、标题等
标签: c# json listview windows-phone-8.1