.xaml
<ComboBox Grid.Row="0" Grid.Column="1" x:Name="cbx_srchResOrg" HorizontalAlignment="Stretch" Style="{DynamicResource ComboBoxStyle}"
ItemsSource="{Binding InfoCombo}" SelectedIndex="0" DisplayMemberPath="Dis_name" SelectedValuePath="Hide_id" SelectedItem="{Binding SelectInfo}"/>
Here is a part of my source code. Why 'SelectedIndex=0' is not working? I want to select [0] value to default at first time, but it just empty box at run time. There are no errors except it. How can I fix it?
As Hej said, you have binded the SelectedItem
with a property in your view model which was null
.
You can fix this by assigning the SelectedItem
in your Viewmodel constructor
Public MyViewModel()
{
SelectInfo = InfoCombo[0];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With