1

I will show you the exact code and output of the code...

This is my linq .dbml file

enter image description here

This i the combobox cbx_contact code :

 <ComboBox Height="22.669" Margin="107.769,43.75,424.266,0" Name="cbx_contact" VerticalAlignment="Top" IsTabStop="True" SelectedValuePath="ContactID" IsSynchronizedWithCurrentItem="True" IsEditable="True" IsTextSearchEnabled="True">
        <ComboBox.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <TextBlock Text="{Binding Path=ContactName}"/>
                    </Grid>
            </DataTemplate>
        </ComboBox.ItemTemplate>
    </ComboBox>

This is the .cs file :

public Contacts()
    {
        InitializeComponent();
        DataClasses1DataContext db = new DataClasses1DataContext();
        cbx_contact.ItemsSource = db.Contacts;
        cbx_contact.SelectedIndex = 0;     
    }

This is the output view of the combobox :

enter image description here

enter image description here

Here in the drop down list of combobox i get all the values but when i select any value the text does not change it gives Contact_Manager.Contact....

I dont know what i am missing here... I have binded combobox like this before also it was working at that time but here it is creating probs... thanks in advance for the help...

Saral Doshi
  • 326
  • 1
  • 5
  • 14
  • This is a duplicate of http://stackoverflow.com/questions/1844156/wpf-iseditable-true-combobox-filled-with-objects-displays-the-tostring-as-the-s – Andrew Shepherd Apr 23 '11 at 08:23
  • @andrew shepherd : sorry for that i searched it on stackoverflow but was searching with wrong key words... thanks again – Saral Doshi Apr 23 '11 at 10:58
  • it's something we all do :-) http://stackoverflow.com/questions/1122928/generate-a-unique-temporary-file-name-with-a-given-extension-using-net – Andrew Shepherd Apr 23 '11 at 11:14

1 Answers1

1

Applying the concepts from this answer:

<ComboBox Height="22.669" Margin="107.769,43.75,424.266,0" Name="cbx_contact" VerticalAlignment="Top" IsTabStop="True" SelectedValuePath="ContactID" IsSynchronizedWithCurrentItem="True" IsEditable="True" IsTextSearchEnabled="True" 
        TextSearch.TextPath=ContactName
         >
        <ComboBox.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <TextBlock Text="{Binding Path=ContactName}"/>
                    </Grid>
            </DataTemplate>
        </ComboBox.ItemTemplate>
    </ComboBox>
Community
  • 1
  • 1
Andrew Shepherd
  • 44,254
  • 30
  • 139
  • 205