There is a code like this:

public class A { public string Name { get; } public object SomeThing { get; } } public ObservableCollection<A> AList { get; } = new ObservableCollection<A>(); 

And there is a ListBox whose elements need to bind to the elements of the AList collection. More precisely only on their Name property. Here's how to do it? Just to not distribute it in two collections. I would not want to.

 <ListBox.ItemTemplate> <DataTemplate> <TextBox/> </DataTemplate> </ListBox.ItemTemplate> 
  • and xaml show how you tried? - Grundy
  • 3
    DisplayMemberPath = "Name" - vitidev
  • @Grundy and I haven’t tried it yet. I don’t know how to divide the list items into Name and Something. - PECHAIRTER
  • one
    @vitidev: You are too strict, the TC did not know. But it will bring Google here later :) - VladD
  • one
    @DarkByte columns have a Binding = {Binding Name}. Cannot use DisplayMemberPath and ItemTemplate. And in the ItemTemplate you need to do ... = {Binding Name}. - vitidev

0