Is there a way to set the initial value of a databound combo box in XAML?
Here is my combo box:
<ComboBox
IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding Source={StaticResource NHibernateTypes}}"
SelectedValue="{Binding ElementName=IdentifierPoperty, Path=PropertyType}"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Grid.Row="1"
Grid.Column="1"
Margin="0,5,10,0"/>
The ItemsSource is an ObjectDataProvider that gets values from an enum. I would like to have the the first value in the enum displayed in the combo box by default. I tried setting SelectedIndex="0", but nothing happened.
Here's the really odd thing. I have a half dozen of these combo boxes in my window, all declared in the same manner as above. About half of them show the first value in their enum by default, but the others are blank. I have verified that all the bindings are working--each combo box shows the correct drop-down when I click it.
Is there a way to explicitly set a default index value for these combo boxes? Is there any reason some sombo boxes would show a value by default while others do not? Thanks for your help.
David Veeneman
Foresight Systems