-
populate combobox
I am currently populating a combobox as follows:
private void PopulateHealthLevels()
{
List<clsStudentDetails> healthlevels = new List<clsStudentDetails>();
healthlevels = clsStudentAccess.GetHealthLevels();
foreach (clsStudentDetails details in healthlevels)
{
cboHealth.Items.Add(details.HealthLevelName);
}
}
Question:
This is what I have in xaml:
Name="cboHealth" SelectedIndex="{Binding Path=HealthLevelID}"
The selectedindex does not seem to be working correctly.
No matter which student I choose, the item shown is always the same.
Note that there are items populated in th ecombobox.
Thanks
-
Re: populate combobox
Use the SelectedItem property instead, and have it bound to an instance of an item in the list.