i've been through tons of attempts and forum posts but i still can't solve my issue.
ISSUE A combobox displaying data from an entity framework dbcontext does not display the selected value but DOES work for the item list. The selected item just shows
System.Data.Entity.DynamicProxies.Equipment_37EBC79AEAECCCCD132FD15F1C9172DF4DD402B322A9C5762AE640F03887F702
BUT the list of the combobox displays correctly....
SETUP I have a dbcontext that contains a class named equipment. Equipment has two items i want to display String Tag; Location.Name;
Selected Item Busted, List Works
<ComboBox x:Name="cbxCopyTo" Grid.Row="2" Grid.Column="1"
IsEditable="True" IsTextSearchEnabled="True" IsTextSearchCaseSensitive="False"
ItemsSource="{Binding}">
<ComboBox.SelectedValue>
<DataTemplate>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" >
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} ({1})">
<Binding Path="Tag" />
<Binding Path="Location.Name" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</ComboBox.SelectedValue>
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" >
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} ({1})">
<Binding Path="Tag" />
<Binding Path="Location.Name" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
You can see above i even tried explicitly setting the selected value; but it didn't work. I did notice when i tried using a converter that it was never called for SelectedItem or SelectedValue when i put converters in there.
The below works if i ignore location (got from datasource drag and drop). This show both the list and selected item correctly.
<Label Grid.Row="1" Grid.Column="0" Content="Copy From:" />
<ComboBox x:Name="cbxCopyTo" Grid.Row="1" Grid.Column="1"
IsEditable="True" IsTextSearchEnabled="True" IsTextSearchCaseSensitive="False"
DisplayMemberPath="Tag" ItemsSource="{Binding}">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
Please help; i would be greatly appreciated!