Reputation: 21211
I have a list of States in an ItemsControl, the DataTemplate is a CheckBox. I would like to add a function to select(check) all states. However I need to loop through the CheckBoxs rather then the data items since the checked state is stored in a separate data structure then the list of states the ItemsControl's ItemSource is bound to.
Upvotes: 1
Views: 566
Reputation: 21211
In the data template I subscribed to the checkbox's onload event. And in the event handler I add the checkbox reference to a generic list of checkbox.
Upvotes: 0
Reputation: 50038
Have a property in your DataObject called IsChecked and bind that to the Checkbox in DataTemplate(Default is TwoWay)
Upvotes: 1