【发布时间】:2011-06-07 16:02:33
【问题描述】:
我在 ListBox 中有一个 CheckBox。我将 ListBox ItemsSource 设置为代理商列表。代理有财产
public class Agency
{
public bool isSelected { get; set;}
}
<ListBox> <!-- ItemsSource set in codebehind to List<Agency> -->
<CheckBox IsChecked="{Binding Path=isSelected, Mode=TwoWay}" />
</ListBox>
我有一个检查所有复选框的功能
//SelectAll button
private void SelectAll_Click(object sender, RoutedEventArgs e)
{
List<Agency> list = this.AgencySubListBox.ItemsSource as List<Agency>;
for (int i = 0; i < list.Count; i++)
{
Agency d = list[i];
d.isSelected = true;
}
}
当我点击全选按钮时,我希望所有复选框都被选中。但什么也没有发生。
【问题讨论】:
标签: wpf data-binding