wpf - WPF: How can I use tag for specifying button's action?
问题描述
I want to make a student's list
so I used ItemsControl and Stackpanel to print student's name
And there's a button next to student's name (as a label)
So what I want to do is when I click the button the student's name is removed from the list
Here's my ItemsControl codes:
<ItemsControl x:Name="input_list" Grid.Column="0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Button Height="25" Width="25" Style="{StaticResource ReturnButton}">
<StackPanel>
<Image Source="/remove_button.png" RenderSize="15 15" Stretch="Fill"/>
</StackPanel>
</Button>
<Label Margin="5 0 0 0" Style="{StaticResource DefaultFont}" Content="{Binding StudentName}" FontSize="20" FontWeight="DemiBold"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
解决方案
推荐阅读
- c# - 在没有按钮事件(如 Excel)的 WPF 程序中验证文本框
- python - 有没有更好的pythonic方法来重写while循环?
- java - 无法在模拟器、Android Studios 上检测到位置
- mysql - MySQL查询-所有时间总计/过去N天总计
- javascript - 如何设置空值或空值在 Jquery 更改中不起作用
- c# - 如何通过单击按钮获取 Xamarin Forms 中的表单字段
- r - 在R中将变量切割成碎片
- python - Python pandas-自动化excel表
- multithreading - 使用 scala 运行框架 2.7
- python - 使用 nltk 来取回原始词和整个句子以进行标记