I've got a editable combobox where I'm using an ItemTemplate that uses MultiBinding. The items displayed when the combobox is expanded display as I expect. However, when an item is selected the text displayed is the object type instead. I've seen posts that suggest overriding ToString(), but I'd like to avoid that if possible.
The object I'm bound to is a collection of UserDetail objects, among other UserDetail has a First and Last Name and an BarcodeID that I'm displaying as a string for each item in the ComboBox. I want to display that same string as the selected item. Instead what I'm seeing is MyNameSpace.UserDetail
Here's the xaml for my combobox. Please tell me where I'm going wrong:
<ComboBox IsEditable="True" IsReadOnly="False" Name="myUser"
TextBoxBase.TextChanged="myCombo_TextChanged"
SelectionChanged="myCombo_SelectionChanged">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{1}, {0}, {2}">
<Binding Path="FirstName" />
<Binding Path="LastName" />
<Binding Path="BarcodeId" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
FYI, The BarcodeID is for an optional barcode badge reader.
You should only bind text data to a combobox that has IsEditable = true.
Remove
IsEditable="True"
See here for more info.