0
我想通過下面的代碼得到一個列表框項目。基本上我想要做的是創建一個tempdatelist,然後將Listbox的itemsource設置爲tempdatelist。Windows Phone 7 Listbox.ItemContainerGenerator.ContainerFromIndex(i)返回null?
if (App.Saveholidayplan[App.selectedlistindex].travel.Count > 0)
foreach (var dictobj in App.Saveholidayplan[App.selectedlistindex].travel[0].DummyRepository)
tempdatelist.Add(dictobj.Key);
lst_mainlist.ItemsSource = tempdatelist;
ListBoxItem item = this.lst_mainlist.ItemContainerGenerator.ContainerFromIndex(i) as ListBoxItem;
//* item is alway null, that is the problem
if(item != null)
但在上面的代碼項目retuns空。
當我在網上查詢一些建議致電ItemContainerGenerator.StatusChanged
事件。
但我無法在WP7中找到此事件? 在WP7中是否存在StatusChanged事件,如果不存在替代方案?
顯示更多的代碼的youre,所以我們可以看到你已經包括 –
編輯我的問題與代碼上下文中的片段的背景下 –
一旦你得到它,你會用'item'做什麼?我不確定你爲什麼在這裏搞亂了ItemContainerGenerator。 – Robaticus