I have encountered the following problem:
ISSUE: ComboBoxItems displaying perfectly but displaying whole object when items are selected.
1. Clicking on comboBox: ComboBoxItems displaying perfectly
2. One ComboBoxitem is selected: Whole Entity Framework object is displayed instead of just item name.
Here is an example of what is displayed when a ComboBoxItem is selected: System.Data.Entity.DynamicProxies.tblContainer_C0BE4F13C798ED380A1E249BFB338D265E97D4F4C7A880C5D813102738561025
Desired result: Bout verre bouchon emery
This is a minified version of my code:
<ComboBox IsEditable = "True" ItemsSource="{Binding ProductsContainer}" SelectedValuePath="ContainerID">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock
FontSize="15"
Width="100"
HorizontalAlignment="Center"
Text="{Binding ContainerName}"
TextWrapping="Wrap" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
Here is the list to which the ComboBox binds:
public virtual List<tblContainer> ProductsContainer { get { return db.tblContainer.ToList(); } }
ProductsContainer has the attributes: ContainerID and ContainerName