XAML itself

<ComboBox x:Name="comboBox" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Width="350" Height="auto" IsEditable="True" PreviewTextInput="comboBox_PreviewTextInput" ToolTip="Введите первые 3 буквы фамилии" Padding="5,5,5,5" SelectionChanged="comboBox_SelectionChaned" > <ComboBox.ItemTemplate> <DataTemplate> <TextBlock> <TextBlock.Text> <MultiBinding StringFormat="{}{0} {1} {2} {3} {4:dd.MM.yyyy}"> <Binding Path="id"/> <Binding Path="fam"/> <Binding Path="name"/> <Binding Path="parent"/> <Binding Path="DOB"/> </MultiBinding> </TextBlock.Text> </TextBlock> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> 

That is not correctly displayed

This is how the combobox list is filled.

  var result = db.Athletes .AsEnumerable() .Where(c => c.fam.ToLower().StartsWith(comboBox.Text.ToString())) .Select(c => new { c.id, c.fam, c.name, c.parent, c.DOB } ) .Take(20) .ToList() ; comboBox.IsDropDownOpen = true; comboBox.ItemsSource = result; 

This gets a combobox enter image description here

  • You don't seem to have a Template . Show more code (and your DataContext ) - VladD
  • What do you have in DataContext? - VladD
  • I confirm, your code works correctly for me. Try the same on a new project. - VladD
  • By the way, do you have any global styles or something similar? - VladD
  • There is nothing like that, the string List is displayed when selected. I don’t know how to disassemble it to be without it {id = 15, fam = "", name, etc.} with select - Dmitry Valeryevich

1 answer 1

In my code, everything is displayed well and correctly.

 <Grid x:Name="LayoutRoot"> <ComboBox ItemsSource="{Binding Items}" Height="25"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock> <TextBlock.Text> <MultiBinding StringFormat="{}{0} {1} {2} {3:dd.MM.yyyy}"> <Binding Path="fam" /> <Binding Path="name" /> <Binding Path="parent" /> <Binding Path="DOB" /> </MultiBinding> </TextBlock.Text> </TextBlock> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> </Grid> 

I use it like this.

  • When choosing from the list it turns out like this {fam = Semenov, name = Semyon, parent = Semenovich, DOB = 06/17/2016 15:41:41}, but I want Semenov Semyon 06/17/2016 - Dmitry Valeryevich
  • I have output like "like". Is it exactly the template inside your combo box? xaml whole copy. - Arheus