我正在尝试设置一个列表框,用户可以通过单击要删除的每个值来删除项目。 我为我的列表框(DisplayName是项类的成员)设置了样式,以包括每个项目的按钮:
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding DisplayName}" />
<Button Content="[x]" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
现在我遇到了一个问题,无法设置按钮来删除关联的条目。 有谁能指点一下吗? 非常感谢。