Get the item doubleclick event of listview

Sauron picture Sauron · May 30, 2009 · Viewed 103.3k times · Source

What do I need to do in order to reference the double click event for a listview control?

Answer

Oliver picture Oliver · Nov 23, 2009
<ListView.ItemContainerStyle>
    <Style TargetType="ListViewItem">
        <EventSetter Event="MouseDoubleClick" Handler="listViewItem_MouseDoubleClick" />
    </Style>
</ListView.ItemContainerStyle>

The only difficulty then is if you are interested in the underlying object the listviewitem maps to e.g.

private void listViewItem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
    ListViewItem item = sender as ListViewItem;
    object obj = item.Content;
}