Is it possible to customize the Results View in ICollectionView?

Now i have so

public ICollectionView PersonsView { get { source = new CollectionViewSource(); source.Source = parent.Persons; return source.View; } } 

enter image description here

Later, I fill in this ComboBox ( ItemsSource="{Binding Data.PersonsView}" ).

Everything works, but I need what would be displayed in the ComboBox - the first and last name for example, and now only the first name is displayed.

How can I do this?

  • show what data you fill in the Combobox and xaml markup - Gardes
  • @ S.Kost added! - kxko
  • now try to remove the DisplayMember property - Gardes
  • @ S.Kost to no avail. as it was ( - kxko
  • judging by your template, you are shown not only the name, but also the ID. This is true? - Gardes

1 answer 1

Override the ToString() method in the Person class

 public override string ToString() { return string.Format("{0} {1}", firstName, soName); } 
  • Unfortunately, this did not help = ( - kxko
  • Thank you very much ! The essence of your answer was correct) redefined a little different and it all worked =) - kxko pm