Listview 多列表视图UI虚拟化
我有如下代码:Listview 多列表视图UI虚拟化,listview,windows-phone-8.1,winrt-xaml,Listview,Windows Phone 8.1,Winrt Xaml,我有如下代码: <ScrollViewer> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <ListView ItemsSourc
<ScrollViewer>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ListView ItemsSource="{Binding FewItems}" />
<ListView ItemsSource="{Binding ManyItems}" Grid.Row="1" />
</Grid>
</ScrollViewer>
我的问题是第二个列表,它非常大。通常情况下,UI虚拟化会发生,但由于它是在滚动查看器和网格中定义的,因此列表会占用所需的空间。这会导致加载此页面时出现明显的延迟
设置列表的最大高度没有任何好处,因为它会导致列表在外部滚动查看器中自动滚动
我的问题是:
谢谢。将其声明为虚拟化StackPanel
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
。
.
示例:
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.Template>
<ControlTemplate TargetType="ItemsControl">
<Border>
<ScrollViewer>
<ItemsPresenter/>
</ScrollViewer>
</Border>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="Hello Wworld" />
</DataTemplate>
</ItemsControl.ItemTemplate>
虚拟化不能像您观察到的那样在滚动视图中工作。看看您的XAML代码,通过创建结合了FewItems和ManyItems的中间集合并将该集合绑定到单个ListView,应该可以很容易地解决您的问题。如果您需要将FewItems中的项目与许多项目中的项目设置为不同的样式,您可能会遇到一些挑战,但是可以使用样式选择器等克服这些问题。谢谢,但这不起作用。我确实试过类似的东西。
ItemsControl
确实执行虚拟化,但它只对两个项目(两个列表视图)执行虚拟化。第二个列表视图仍然有它所需要的空间,并且没有虚拟化它的项目。是的,这正是我所做的,问题是第二个列表是分组的,而第一个不是,但是我克服了这一点。谢谢。我也遇到了类似的问题,我已经解决了并删除了scrollview,它成功了。我的listview不是那样复杂,但是listview上的所有项目都是可扩展的。当我走到列表的末尾,展开屏幕上的倒数第二项或任何项目,并尝试滚动列表视图时,滚动时,它会自动将我带到列表视图的顶部或中间@丹尼斯,你知道为什么会这样吗?