我有一个带有 ListView 的 Windows 8 应用程序:
<ListView x:Name="EventListView" ItemClick="EventListView_ItemClick_1" IsItemClickEnabled="True"/>
有一些 Event 对象(一个单独的类,具有 EventType、Description、Time 等字符串属性)是 ListView 的来源:
List<Event> eventlist = new List<Event>{
new Event(CONNECTION, "Disconnected", DateTime.Now.ToString(), MONITOR, "SAMSUNG M5", CONNECTION_IMG, RED),
new Event(SYNC, "Synchronised", DateTime.Now.ToString(), LAPTOP, "ASUS X402", SYNC_IMG, BLUE),
new Event(WARNING, "Overheated!", DateTime.Now.ToString(), PRINTER, "CANON MP280", WARING_IMG, YELLOW),
};
EventListView.ItemsSource = eventlist;
我试图访问点击项目的信息,但它似乎没有设置:
private void EventListView_ItemClick_1(object sender, ItemClickEventArgs e)
{
Event item = sender as Event;
GetInfoText.Text = item.Description.ToString();
}
如何获取单击项目的事件属性?