的項目考慮代碼:迭代通過CompositeCollection
ObservableCollection<string> cities = new ObservableCollection<string>();
ObservableCollection<string> states = new ObservableCollection<string>();
ListBox list;
cities.Add("Frederick");
cities.Add("Germantown");
cities.Add("Arlington");
cities.Add("Burbank");
cities.Add("Newton");
cities.Add("Watertown");
cities.Add("Pasadena");
states.Add("Maryland");
states.Add("Virginia");
states.Add("California");
states.Add("Nevada");
states.Add("Ohio");
CompositeCollection cmpc = new CompositeCollection();
CollectionContainer cc1 = new CollectionContainer();
CollectionContainer cc2 = new CollectionContainer();
cc1.Collection = cities;
cc2.Collection = states;
cmpc.Add(cc1);
cmpc.Add(cc2);
list.ItemsSource = cmpc;
foreach(var itm in cmpc)
{
// itm is CollectionContainer and there are only two itm’s
// I need the strings
}
在列表中顯示的GUI
我需要這個數據(不涉及到ListBox)正確的數據,我沒有得到它
他是一個很好的把戲。有沒有辦法直接做到這一點? ListBox如何看到字符串?它使用什麼? – Dudu 2010-06-09 11:06:27
你是直接指什麼? – 2010-06-09 11:50:23
東西在線:foreach(var itm in cmpc) – Dudu 2010-06-14 09:01:02