我正在创建wp8 app并且有一个大型数据集来表示itemscontrol控件。问题是由于元素的大小,我失去了很多记忆。如何检查itemscontrol项是否在视口中?
这是我使用的xaml:
<ItemsControl x:Name="showList" Margin="0" ItemsSource="{Binding tmp}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"></StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0,2,0,0" Background="#FF2E2E2E" Width="280">
<Image Source="../Images/edge_shadow_x8.png" HorizontalAlignment="Left" Stretch="Fill" Width="8" Margin="0,0,2,0"/>
<TextBlock x:Name="time" FontSize="16" Text="{Binding StartTime}" Width="50" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="15,0" Foreground="White" TextWrapping="Wrap"/>
<TextBlock x:Name="show" FontSize="16" Text="{Binding title}" Width="160" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,5,10,5" TextWrapping="Wrap"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</ScrollViewer>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>