I did not find a way to find control defined in the DataTemplate either. But if you are trying to find which one is checked there are several ways:
1) Hook a event handler to the CheckBox:
<CheckBox x:Name="chkCourse" Content="{Binding CourseName}"
Margin="5" Tag="{Binding CourseId}" Click='chkCourse_Click"></CheckBox>
private void CheckBox_Click(object sender, RoutedEventArgs e)
{
CheckBox c = sender as CheckBox; // Here is the one that user just clicked
//do something with it.
}
2) Check the data that bound to the Checkbox.IsChecked field:
In your Data Item you can add a property for your Cource object:
public bool CourseSelected {get;set;};
then bind this property to the ChechBox.IsChecked field:
<CheckBox x:Name="chkCourse" Content="{Binding CourseName}" Margin="5" Tag="{Binding CourseId}" IsChecked="Binding CourseSelected, ,Mode=TwoWay}"></CheckBox>
If the checkbox is checked, courseTables[index].IsChecked = true;
sladapter
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question