I have a ComboBox in my WPF application where I display a list of items. Most of the times the first item is the correct choice in the itemssource list, only sometimes on a personal request the item could be changed. Now My combo box loads the list but never shows the first item at selected Item. Can anybody help me please. here's my code.
XAML:
<ComboBox Name="cbxShipTo" TabIndex="0" IsTextSearchEnabled="True" ToolTip="Ship To is a Required Field" MinWidth="200" SelectedIndex="0" IsSynchronizedWithCurrentItem="True"
IsEditable="False" DisplayMemberPath="ShipToCountyState" SelectedValuePath="ShipToValue">
<ComboBox.SelectedValue>
<Binding Path="ShipToQAD" Mode="TwoWay">
<Binding.ValidationRules>
<common:RequiredValidationRule ErrorMessage="Ship To is a Required Field" />
<ExceptionValidationRule></ExceptionValidationRule>
</Binding.ValidationRules>
</Binding>
</ComboBox.SelectedValue>
Code Behind:
cbxShipTo.ItemsSource = dbLookupService.GetShipToByCustomer(_inspectionListItems[0].CompanyID);
cbxShipTo.SelectedItem = cbxShipTo.Items.GetItemAt(0);
I have values in itemsSource, Selected itme hasa a value too, but never gets displayed on the screen.
Any help is appreciated.