what is the actual difference between Recycling/Standard of VirtualizationMode property in VirtualizingStackPanel?

后端 未结 1 1687
轻奢々
轻奢々 2021-01-01 12:36

What is actually happening in VirtualizingStackPanel.VirtualizationMode = Recycling/Standard.?

相关标签:
1条回答
  • 2021-01-01 13:13

    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 |  
    

    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 |  
    

    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.

    When VirtualizationMode is set to Standard, the VirtualizingStackPanel will create and discard item containers instead of reusing them.

    0 讨论(0)
提交回复
热议问题