ScrollViewer禁用UI虚拟化 [英] ScrollViewer disables UI Virtualization

查看:75
本文介绍了ScrollViewer禁用UI虚拟化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我需要一些小问题的指导.是否可以将ScrollViewer ListBox和其他项目放入而不丢失其UI虚拟化功能.非常感谢.

我的代码:

< ScrollViewer x:Name =" MyScrollViewer" VerticalScrollBarVisibility ="Auto">
  < DockPanel LastChildFill =真">
     < Grid DockPanel.Dock ="Top"高度="300"/.
     < Grid DockPanel.Dock ="Top"高度="300". />
     < ListBox x:Name =" ListBox1" DockPanel.Dock =底部" ItemsSource ="{Binding CollectionCvs.View,IsAsync = True}"
                       VirtualizingStackPanel.IsVirtualizing =真".
                       VirtualizingStackPanel.VirtualizationMode =回收". >
       <!-< ListBox.GroupStyle>
            < GroupStyle ContainerStyle =" {StaticResource GroupHeader}" />
        </ListBox.GroupStyle>->
     </ListBox>
  </DockPanel>
</ScrollViewer> 

有人知道如何解决此问题.

解决方案

ScrollViewer为其子级提供无限的空间,除非它只有一个实现IScrollInfo的子级. UI虚拟化不适用于无限规模的容器,因此在这种情况下将其关闭.

因此,在您的情况下,恐怕无法用某些容器对象包装在ListBox中显示的集合,该容器对象包含有关要显示的项目类型的信息并在自定义DataTemplateSelector中使用该信息.


Hi, I need a little guidance with such a small problem. Is it possible to put into ScrollViewer ListBox and other items without ever losing its UI virtualization. Thanks a lot.

my code:

<ScrollViewer x:Name="MyScrollViewer" VerticalScrollBarVisibility="Auto">
  <DockPanel LastChildFill="True">
     <Grid DockPanel.Dock="Top"  Height="300"/>
     <Grid DockPanel.Dock="Top" Height="300" />
     <ListBox x:Name="ListBox1" DockPanel.Dock="Bottom" ItemsSource="{Binding CollectionCvs.View, IsAsync=True}"
                       VirtualizingStackPanel.IsVirtualizing="True"
                       VirtualizingStackPanel.VirtualizationMode="Recycling"  >
       <!--<ListBox.GroupStyle>
            <GroupStyle ContainerStyle="{StaticResource GroupHeader}" />
        </ListBox.GroupStyle>-->
     </ListBox>
  </DockPanel>
</ScrollViewer>

Does anyone know how to solve this problem.

解决方案

ScrollViewer provides infinite space to its children unless it only has a single child that implements IScrollInfo. UI Virtualization does not work with containers measuring at infinite scale thus its turned off in that case. 

So in your case I'm afraid there's no way around wrapping the collection displayed in your ListBox by some container object containing information about the type of item to display and utilize that information in a custom DataTemplateSelector.


这篇关于ScrollViewer禁用UI虚拟化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆