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;
}
}
您可以将ListBox的ItemsSource绑定到ObservableCollection(!必须为属性),然后在ListBox上设置DisplayMemberPath="Item1"
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.