Reputation: 25
I am populating listview as follows in windows 8.1 app using c#
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; }
}
This gives me a proper listView. I want to handle the itemClick event. For corresponding "id" in the JSON response there is a "title" , "content" and "sender" of the notice. So once I click on any listview item corresponding notice should be shown. The following is a part of my JSON response
{
"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"
}
In the list View only "title" and "from" is shown. But after clicking it should display title, content, sender. Any help?
Upvotes: 0
Views: 739
Reputation: 15296
Set IsItemClickEnabled
property to true and use ItemClick
click event in ListView
. You can access clicked item by accessing its argument object ItemClickEventArgs
, i.e. e.ClickedItem
where e
is ItemClickEventArgs
Upvotes: 1