我有一個列表框,裏面包含一個帶有Image和TextBlock控件的數據模板。我想首先,把網格容器列表框內Datatemplate內的容器在列表太長時爲空
<ListBox x:Name="NewsList" Margin="0,0,20,0" SelectionChanged="NewsList_SelectionChanged" />
<DataTemplate>
<Grid Width="400" Height="89">
<Image HorizontalAlignment="Left" Width="64" x:Name="ImageThumbnail" Height="64" VerticalAlignment="Top" Margin="0,10,0,0" Source="http://vnexpress.net/Files/Subject/3B/A2/3B/15/top.jpg"/>
<TextBlock Text="{Binding Title}" Margin="78,0,8,0" TextWrapping="Wrap" FontSize="26.667" Height="74" VerticalAlignment="Top"/>
</Grid>
</DataTemplate>
</ListBox>
for (int i = 0; i < feeds.Count; i++)
var containerItem = list.ItemContainerGenerator.ContainerFromIndex(i);
得到ImageControl出來,當我設置NewsList.Items =訂閱與feeds.Count超過23,一些containerItem爲null。如果它小於23,我永遠不會得到一個空容器。
有誰知道是什麼原因以及如何修復它。如果我們可以有另一種方式來獲取imageControl
看你的樣品,你可能還需要給我們帶有LowProfileImage控件的DeferredLoadListBox控件 - http://blogs.msdn.com/b/delay/archive/2010/10/04/there-s-no-substitute-for-customer-feedback-improving-windows- phone-7-application-performance-now-a-bit-more-with-lowprofileimageloader-and-deferredloadlistbox-updates.aspx – DevTheo 2010-12-03 17:06:38