获得点击ListView项属性 [英] Get Clicked ListView item attributes

查看:223
本文介绍了获得点击ListView项属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ListView一个Windows 8应用:

I have a Windows 8 application with a ListView:

<ListView x:Name="EventListView" ItemClick="EventListView_ItemClick_1" IsItemClickEnabled="True"/>

有一些活动对象(用绳子一个单独的类属性,如事件类型,描述,时间等),它是ListView控件来源:

There is some Event objects (a separate class with string attributes like EventType, Description, Time, etc..) that is the source of the 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;

我试图访​​问单击项目的信息,但它似乎没有设置:

I tried to access the info of the clicked item, but its seems to be not set:

private void EventListView_ItemClick_1(object sender, ItemClickEventArgs e)
{
    Event item = sender as Event;
    GetInfoText.Text = item.Description.ToString();
}

我怎么能获得点击的项目的事件属性?

How could I get the event attributes of the clicked item?

推荐答案

事件对象存储在电子参数:

private void EventListView_ItemClick_1(object sender, ItemClickEventArgs e)
{
    Event item = e.ClickedItem as Event;
    GetInfoText.Text = item.Description.ToString();
}

我相信发件人参数是列表视图。

这篇关于获得点击ListView项属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆