ComboBox is displaying System.Data.DataRowView no matter what is selected. ItemTemplate Issue

I have a ComboBox that needs to display multiple fields in it's drop down. but only wants to store one. Right now it works to display multiple fields. but no matter what I select, the value shown in the textbox is "System.Data.DataRowView". Does anyone know why this is or how to fix it?

<ComboBox ItemsSource="{Binding Vwr.Table.Tbl, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
  x:Name="Supplier"
  SelectedValuePath="Name"
  SelectedValue="Name"
  IsEditable="True" Style="{StaticResource tabTextBox}"
    DataContext="{Binding parties}">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="SelectionChanged">
            <i:InvokeCommandAction Command="{Binding SupplierChangedCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <ComboBox.ItemTemplate>
        <DataTemplate>
            <TextBlock>
                <TextBlock.Text>
                    <MultiBinding StringFormat="{}{0}: {1}: {2}">
                        <Binding Path="Name"/>
                        <Binding Path="Funds"/>
                        <Binding Path="Terms"/>
                    </MultiBinding>
                </TextBlock.Text>
            </TextBlock>
        </DataTemplate>
    </ComboBox.ItemTemplate>
</ComboBox>

Upvotes: 1

Views: 243

Answers (1)

Found the answer here :http://www.shujaat.net/2010/08/wpf-editable-combobox-with-datatemplate.html

The solution was to set TextSearch.TextPath. In my case, it was

TextSearch.TextPath="Name"

Updating my original code (unnecessary parts removed for brevity), the working version is here

<ComboBox 
  x:Name="Supplier"
  ItemsSource="{Binding Vwr.Table.Tbl}"
  SelectedValuePath="Name"
  SelectedValue="Name"
  IsEditable="True" Style="{StaticResource tabTextBox}"
  TextSearch.TextPath="Name"
  DataContext="{Binding parties}">

Hope this helps people out there!

Upvotes: 2

Related Questions