我有一个基本的 ListView,它的 XAML 可以在下面找到。基本上,在我填充东西之后,我希望能够删除它们,因此“X”按钮:
<ListView Name="selectedPeople" ItemsSource="{Binding Path=map, RelativeSource={RelativeSource AncestorType=Window},
Mode=OneWay}" Width="480" Height="200" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,225,10,0"
SelectionChanged="selectedPeople_SelectionChanged">
<ListView.View>
<GridView AllowsColumnReorder="True" ColumnHeaderToolTip="Broadcast call targets">
<GridViewColumn DisplayMemberBinding="{Binding Path=Key}" Header="ID" Width="120" />
<GridViewColumn DisplayMemberBinding="{Binding Path=Value}" Header="Description" Width="320" />
<GridViewColumn Header="" Width="30">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Button Content=" X " Visibility="Hidden" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
默认情况下,我使 X 按钮不可见,因为所需的行为是它只在选中行时出现。如何做到这一点,即更改所选更改按钮的可见性?此外,一旦单击,我如何关联按钮与哪个行/项目相关联?