I have a ListBox
in my wpf window that binds to an ObervableCollection
. I want to open the browser if someone clicks on an element of the ListBox
(just like a link). Can someone tell me how to do this? I found something with listboxviews, does it only work this way or is there a way by just using the ListBox
?
Yours
Sebastian
You can add a style to ListBox.ItemContainerStyle, and add an EventSetter there:
<ListBox>
....
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<EventSetter Event="MouseDoubleClick" Handler="ListBoxItem_MouseDoubleClick"/>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
ListBoxItem_MouseDoubleClick is a method in your code behind with the correct signature for MouseDoubleClick.