开发者

ListViewItem in WPF ListView

I'm attempting to get the ListViewItem object from the currently s开发者_运维百科elected row of a data bound ListView, like so:

ListViewItem selectedItem = new ListViewItem();
selectedItem = (ListViewItem)listView1.Items[index];

what this does however, is returns the object type the ListView is bound to, in this instance, its a company class object for a database. What I would like it to return is the actual ListViewItem object itself (so that I can access its properties).

is there anyway to do this?

thanks


You have to use,

ListViewItem selectedListView = 
    (ListViewItem)listView1.ItemContainerGenerator.GetContainerForItem(
        listView1.Items[index]);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜