Reputation: 14694
how can I get the clicket elevent from a ListView
which has the IsItemClickEnabled
enabled?
I know how to get the selected Item/Index but not the clicked item.
ItemClick
is working but I can not say s.th. like:
Object selection = listView1.SelectedItem;
EDIT: I have a ListView and I need to catch the clicked item from this list in the following method:
private void listView1_ItemClick(object sender, ItemClickEventArgs e)
{
...
}
Upvotes: 0
Views: 2023
Reputation: 2916
I guess you can also try the SelectionChanged
event, and get the clicked item as e.AddedItems
or MyListView.SelectedItem
or MyListView.SelectedItems
.
Upvotes: 1
Reputation: 23774
I may be missing something, but doesn't the following work for you?
private void lv_ItemClick_1(object sender, ItemClickEventArgs e)
{
var item = e.ClickedItem as String;
}
Here I assume the items in the list are simple strings, but in general they'll be whatever type you are using in the collection you've bound to the ItemsSource property of the ListView.
Upvotes: 3