问题描述
VirtualizingStackPanel.VirtualizationMode =回收/标准中实际上发生了什么?
What is actually happening in VirtualizingStackPanel.VirtualizationMode = Recycling/Standard.?
推荐答案
当VirtualizationMode
设置为Recycling
时,VirtualizingStackPanel
将重用项目容器,而不必创建新的容器.如果我们从这里开始
When VirtualizationMode
is set to Recycling
, the VirtualizingStackPanel
will reuse item containers instead of having to create a new one. If we start out with this
-------------------------
| Container 1 | Data 1 |
-------------------------
| Container 2 | Data 2 |
-------------------------
| Container 3 | Data 3 |
然后向下滚动一个位置,以便将数据1滚动到视图之外,将数据4滚动到视图中,然后Recyling将获取数据1的项目容器,并将其重新用于数据4.
And scroll one position down, so Data 1 is scrolled out of view and Data 4 is scrolled into view then Recyling will take the item container for Data 1 and reuse it for Data 4.
-------------------------
| Container 2 | Data 2 |
-------------------------
| Container 3 | Data 3 |
-------------------------
| Container 1 | Data 4 |
在为Item容器使用附加属性时,我遇到了一些问题,例如,如果我为Container 1进入了编辑模式,则为绿色背景.由于仍设置了Attachd属性,向下滚动,数据4也将具有绿色背景. .
I've had some problems with this when using attached properties for the Item container, e.g Green background if I have entered edit mode for Container 1. Scrolling down and Data 4 will also have Green background since the Attached Property was still set.
VirtualizationMode
设置为Standard
时,VirtualizingStackPanel
将创建和丢弃项目容器,而不是重复使用它们.
When VirtualizationMode
is set to Standard
, the VirtualizingStackPanel
will create and discard item containers instead of reusing them.
这篇关于VirtualizingStackPanel中的Recycling/Standard of VirtualizationMode属性之间的实际区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!