本文介绍了WPF ListBox VirtualizingStackPanel.VirtualizationMode =“回收"会导致相同的列表项在滚动时始终出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用WPF/.NET 4,当我添加VirtualizingStackPanel.VirtualizationMode ="Recycling"时,属性设置为我的ListBoxes,它会导致滚动时一遍又一遍地重复相同的列表项.例如,假设我有一个100的ListBox 项和10一次可见.当ListBox第一次加载时,我会看到应该出现的项目1-10,但是当我开始向下滚动以查看剩余的项目11-100时,随着向下滚动,项目1-10会一遍又一遍地重复,所以我永远无法查看项目 11-100.如果将回收"改回标准",则一切正常,但滚动速度非常慢(我的ListItem相当复杂,其中包含多个图像,文本字段和按钮).启用回收"时,滚动速度非常快, 但我只能查看项目1-10.关于错误或如何解决的任何想法?预先感谢.


-丹-永远不能做任何事情"

I'm using WPF/.NET 4 and when I add the VirtualizingStackPanel.VirtualizationMode="Recycling" property to my ListBoxes, it causes the same list items to be repeated over and over when scrolling. For example, let's say I have a ListBox with 100 items and 10 are visible at a time. When the ListBox first loads I see items 1 - 10 like I should, but when I start scrolling down to see the remaining items 11 - 100, items 1 - 10 are repeated over and over as I scroll down, so I'm never able to view items 11 - 100. If I change Recycling back to Standard, then everything works correctly, but the scrolling is horribly slow (my ListItems are fairly complex, with several images, text fields, and buttons in them). When Recycling is on, the scrolling is super fast, but I can only ever view items 1 - 10. Any ideas on what's wrong or how to fix it? Thanks in advance.


- Dan - "Can't never could do anything"

推荐答案

尝试设置此属性

 <Setter Property="VirtualizingStackPanel.IsVirtualizing" Value="True"/>
    <Setter Property="VirtualizingStackPanel.VirtualizationMode" Value="Recycling"/>
    <Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="True"/>

ScrollViewer.IsDeferredScrollingEnabled将改善滚动效果


这篇关于WPF ListBox VirtualizingStackPanel.VirtualizationMode =“回收"会导致相同的列表项在滚动时始终出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 07:07