I have a class called People which has STRING name
and STRING ImgPath
. I make a LIST
listOfPeople
which is the source of icCheckBox
.
<DataTemplate x:Key="cBoxTemp">
<StackPanel Orientation="Horizontal" Width="Auto" Height="Auto">
<CheckBox Content="{Binding name}" MouseUp="CheckBox_MouseUp"/>
</StackPanel>
</DataTemplate>
xaml
<ItemsControl Name="icCheckBox" Grid.Column="0" ItemTemplate="{StaticResource cBoxTemp}" Height="Auto" Width="Auto">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
I would like to go through each time a checkbox is changed and populate a new list of the people that are checked.
private void CheckBox_MouseUp(object sender, MouseButtonEventArgs e)
{
// listOfSelectedPeople = new List<Person>();
// For Each (Person e in listOfPeople)
// if(cur.isChecked == true)
// ListofSelectedPeople.add(current);
// ... Once I have this List populated my program will run
}
I cannot get the isChecked
Property of the checkbox because it is a datatemplate
. How could I do this?