I have a CheckBox in a ListBox. I set the ListBox ItemsSource to a List of Agency. Agency has a property
public class Agency
{
public bool isSelected { get; set;}
}
<ListBox> <!-- ItemsSource set in codebehind to List<Agency> -->
<CheckBox IsChecked="{Binding Path=isSelected, Mode=TwoWay}" />
</ListBox>
I have a function to check all the checkboxes
//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;
}
}
When I hit the select all button I expect the checkboxes to all be checked. But nothing happens.