<ListView x:Name="CustomWorkoutListView" ItemsSource="{Binding WorkoutTypeDTO}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto" Style="{DynamicResource ListViewStyle1}" Width="400" Height="119" SelectionChanged="CustomWorkoutSelectionChanged">
<ListView.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<StackPanel>
<StackPanel Margin="0,0,10,8" Name="WorkoutTypeBackground" Visibility="{Binding IsEditable,Converter={StaticResource NegBooleanToVisibilityConverter}}">
<StackPanel.Background>
<ImageBrush ImageSource="/Assets/Images/workout_type_back_unselected.png"/>
</StackPanel.Background>
<TextBlock Name="TextBlockName" Text="{Binding WorkoutTypeName}" Style="{StaticResource WorkoutTypeNameText}"/>
</StackPanel>
<StackPanel Margin="0,0,10,8" Orientation="Horizontal" Visibility="{Binding IsEditable,Converter={StaticResource BooleanToVisibilityConverter}}">
<StackPanel.Background>
<ImageBrush ImageSource="/Assets/Images/workout_type_back_edit.png"/>
</StackPanel.Background>
<TextBlock Text="{Binding WorkoutTypeName}" Style="{StaticResource WorkoutTypeNameText}"/>
<Button BorderThickness="0" Template="{DynamicResource ButtonBaseControlTemplate1}" Name="CrossButton" Width="20" Height="20" Click="DeleteWorkoutType">
<Button.Background>
<ImageBrush ImageSource="/Assets/Images/workout_type_X.png"/>
</Button.Background>
</Button>
</StackPanel>
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter TargetName="WorkoutTypeBackground" Property="Background">
<Setter.Value>
<ImageBrush ImageSource="/Assets/Images/workout_type_back_selected.png"/>
</Setter.Value>
</Setter>
<Setter TargetName="TextBlockName" Property="FontSize" Value="48"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
在上面的代码中,listviewitems 由 Stackpanel 组成,它本身有一个文本块和一个按钮。现在,当我单击按钮时,我怎么知道单击了哪个 listviewitem 以便我可以进行一些操作?