Reputation: 336
I will show you the exact code and output of the code...
This is my linq .dbml file
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 :
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...
Upvotes: 1
Views: 1849
Reputation: 45232
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>
Upvotes: 1