Suppose we have a ComboBox and nested ComboBoxItem in a WPF project:

 <ComboBox Name="People" Height="30" VerticalAlignment="Top" IsEditable="True"> <ComboBoxItem> <StackPanel Orientation="Horizontal"> <TextBlock Padding="0 0 10 0">3845</TextBlock> <TextBlock>Andrew Invanov</TextBlock> </StackPanel> </ComboBoxItem> <ComboBoxItem> <StackPanel Orientation="Horizontal"> <TextBlock Padding="0 0 10 0">3845</TextBlock> <TextBlock>Sergey Petrov</TextBlock> </StackPanel> </ComboBoxItem> <ComboBoxItem> <StackPanel Orientation="Horizontal"> <TextBlock Padding="0 0 10 0">3845</TextBlock> <TextBlock>Valadimir Sidorov</TextBlock> </StackPanel> </ComboBoxItem> <ComboBoxItem> <StackPanel Orientation="Horizontal"> <TextBlock Padding="0 0 10 0">3845</TextBlock> <TextBlock>Nikolay Kuznetsow</TextBlock> </StackPanel> </ComboBoxItem> </ComboBox> 

If you do not intervene in the program part and select an item from the list, then a link to the ComboBoxItem object will be displayed:

enter image description here

Why is this happening and what should be done so that when you select an item in the ComboBox , what is needed is displayed?

  • one
    This happens because you have enabled the editing of the ComboBox . Accordingly, he does not know exactly how to edit complex objects. Read here: stackoverflow.com/questions/1844156/… - trydex
  • better not to fill ComboBox in this way - user227049
  • What do you mean by "how to"? - user227049
  • @Foggy Finder, "as it should," means that when selecting an option in the input field, it was not System.Windows.Controld.ComboBoxItem , but text content, for example, 3845 Nikolay Kuznetsow (besides the text, I also saw examples with pictures). - Gleb
  • To do this, define a template for the list item (or, in simple cases, override .ToString ()) - user227049

0