I fixed it by wrapping the image inside a button:
<listbox height="Auto">
Width="200"
Margin="0"
ItemsSource="{Binding PictureList}">
<listbox.itemtemplate>
<datatemplate>
<stackpanel>
<button background="Transparent">
Click="Button_Click">
<image source="{Binding picture}">
Height="100"
Width="100"/>
</image></button>
</stackpanel>
</datatemplate>
</listbox.itemtemplate>
</listbox>
WIthin the
Button_Click
method I then reference the
fullName
property.
private void Button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show(((Item)(((Button)sender).DataContext)).fullName);
}
It's not pretty so anyone with a more elegant solution please post it here - thanks.