我的ScrollViewer
Silverlight 客户端中有一个显示所选类别中项目的列表。项目在选择时会改变大小。正常情况下ScrollViewer
作品还不错,但一个类有近300项。选择此类别时,ScrollViewer
几乎无法使用。它是否呈现列表中的所有内容?有什么办法可以加快速度吗?
问问题
361 次
1 回答
0
我找到了一个可能有帮助的解决方案:
<!-- This needs to be contained in a parent panel like a grid -->
<ListBox x:Name="Items" >
<ListBox.Template>
<ControlTemplate> <!-- Broke it out to allow resizing -->
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<ItemsPresenter/> <!-- This little fella does magical things -->
</ScrollViewer>
</ControlTemplate>
</ListBox.Template>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel VirtualizingStackPanel.VirtualizationMode="Recycling"/> <!-- Recycle was a must -->
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<HyperlinkButton VerticalAlignment="Top" Margin="5" />
<!-- This guy I did need to set a minwidth on to retain nice and predictable scrolling when datacontext was potentially changing -->
<ContentControl cal:View.Model="{Binding}" MinWidth="1160" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
于 2013-01-03T04:16:07.010 回答