samedi 9 mai 2015

WPF trigger event by clicking on specified content of SelectedItem in ListBox

I have template for ListBoxItems that contains 3 columns. Each item is represented by picture-text-picture. Is there some posibillity how to trigger event (for example PreviewMouseLeftButtonDown) only by clicking on third column in ListBoxItem (not enywhere else on item).

I know how to trigger it by clicking on whole ListBoxItem, but i need it to trigger only when clicked on the last column (picture). Thanks.

<ListBox.ItemTemplate>
 <DataTemplate>
   <Grid Margin="0,4,0,4">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="20" />
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="20" />
       </Grid.ColumnDefinitions>
       <Image Source="images/showFile.png" Grid.Column="0" Height="16" Width="16"/>
       <TextBlock Text="{Binding Name}" Grid.Column="1"/>
       <Image Source="images/delete.png" Grid.Column="2" Height="16" Width="16"/>                        
  </Grid>
 </DataTemplate>
</ListBox.ItemTemplate>   

Aucun commentaire:

Enregistrer un commentaire