I was looking for a way to attach a MouseDoubleClickHandler to the implicitly generated ListViewItems in a databound control:
<ListView ItemsSource="{Binding Instances}" />
For some strange reason all the mouse events seem to be directly routed instead of bubbling like other input events. Only some magic of the framework causes them to be raised for every hit control. This causes the sender to be totally worthless, since it is always the “current” object.
Uncle Google just brought up a useless and wrong answer on the “site with a hyphen.” But after some fiddling I found the answer: just use an EventSetter to set the handler on all items:
<ListView ItemsSource="{Binding Instances}" >
<ListView.Resources>
<Style TargetType="ListViewItem">
<EventSetter Event="MouseDoubleClick"
Handler="OnDoubleClick" />
</Style>
</ListView.Resources>
</ListView>
Then I wanted to post the question and answer to stackoverflow so others can profit from it too. It turns out that this is an already solved problem: WPF ListView: Attaching a double-click (on an item) event. Furthermore, both this page and the linked thread on the MSDN Forum were also available on the google results. Meh.