0

I have created ObservableCollection<Tuple<string,string>> servers; every tuple contains two fields Is it possible to bind this collection to listBox - so, that after binding there are only name strings in this listBox?

the Name String - is the first string from the tuple

private ObservableCollection<Tuple<string,string>> nameVals;

 public ObservableCollection<Tuple<string,string>> NameVals
        {
            get
            {
                if (nameVals == null)
                     nameVals= new ObservableCollection<Tuple<string, string>>(Helpers.getNamesAndValues("ololo"));
                return nameVals;
            }
        }
curiousity
  • 4,703
  • 8
  • 39
  • 59

1 Answers1

3

You can bind the ItemsSource of your ListBox to your ObservableCollection (!must be a property) and set DisplayMemberPath="Item1" on the ListBox.

Giangregorio
  • 1,482
  • 2
  • 11
  • 12