我收集了这样的课程:
public class class1
{
public double first {get;set;}
public double second {get;set;}
public void divide(object sender, RoutedEventArgs e)
{
first/=2;
second/=2;
}
}
ObservableCollection<class1> collection1;
使用 wpf 和数据绑定显示:
<Listbox ItemsSource="{Binding collection1}" >
<ListBox.ItemTemplate>
<DataTemplate>
<WrapPanel>
<TextBox Text="{Binding first}" />
<TextBox Text="{Binding second}" />
<Button Content="Divide" />
</WrapPanel>
</DataTemplate>
</ListBox.ItemTemplate>
我的问题是:我可以以某种方式将每个按钮绑定到它的实例的功能划分吗?