VirtualizingCollectionView
A collection view that presents grouped data to BinaryVirtualizingWrapPanel as one flat list, with each group's header as a row of its own, so that headers are virtualised with the items instead of being generated up front.
public sealed class VirtualizingCollectionView : ListCollectionView
Inherits from / implements: ListCollectionView
Remarks
How this view works. An ordinary grouped view hands an items control its Groups, and the control builds one GroupItem per group with a panel of its own inside - which is exactly what a virtualising panel cannot see through. This view reports Groups as null , so the items control treats it as a flat list, and it inserts the groups into that list itself: Count is the items plus one row per group, GetItemAt answers a CollectionViewGroup for a header row and the item for any other, and IndexOf is its inverse. The real groups are still built by the base class and read through Core . Only the top level is flattened. With more than one group description, the rows are the top-level groups' headers and every item under them; the inner levels get no header row. Telling a header row from an item. A header row reaches the items control as an ordinary item, so its container is an ordinary container. Set CheckForVirtualizedGroupHeadersProperty on the containers (a style setter is the usual way) and this view keeps IsCurrentItemAVirtualizedGroupHeaderProperty true on whichever of them currently holds a group, for a trigger to restyle. Change notifications are translated, or replaced by a reset. Every index this view raises has to count the header rows, or the items control's generator falls out of step with the list. An addition is raised at its row (and its group's header first, when the addition created the group). A removal, move or replacement in a grouped view can empty a group or move an item between groups, so it is raised as a reset, which is always correct; ungrouped, those pass through unchanged, since the rows are then the items.
Members at a glance
VirtualizingCollectionView | Initializes a new instance of the VirtualizingCollectionView class. |
Count | Gets the number of rows in the view: the items, plus one header row for each top-level group when the view is grouped. |
Groups | Always null , so that an items control lays this view out as one flat list, with the group headers among the rows, instead of generating a group item per group. |
GroupsCount | Gets the groups count. |
GetCheckForVirtualizedGroupHeaders | Gets whether to check for virtualized group headers. |
GetIsCurrentItemAVirtualizedGroupHeader | Gets whether the current item is a virtualized group header. |
GetItemAt | Retrieves the item at the specified position in the view. |
IndexOf | Returns the position of an item in the view, counting one row for each group header before it. |
OnCollectionChanged | Raises the CollectionChanged event with its indices counted in rows, header rows included, as the items control reads them. |
SetCheckForVirtualizedGroupHeaders | Sets whether to check for virtualized group headers. |
SetIsCurrentItemAVirtualizedGroupHeader | Sets whether the current item is a virtualized group header. |
SetIsCurrentItemAVirtualizedGroupHeaderProperty | Sets whether the current item is a virtualized group header. The same as SetIsCurrentItemAVirtualizedGroupHeader, which is the name XAML looks for. |
CheckForVirtualizedGroupHeadersProperty | Identifies the attached property that asks this view to keep IsCurrentItemAVirtualizedGroupHeaderProperty up to date on an item container, following the container's data context as it is realised and reused. |
IsCurrentItemAVirtualizedGroupHeaderProperty | Identifies the attached property that is true on an item container whose data context is a group header row. It is kept up to date only on containers that have CheckForVirtualizedGroupHeadersProperty set. |
Constructors
VirtualizingCollectionView
Initializes a new instance of the VirtualizingCollectionView class.
- list
- The underlying collection, which must implement
IList.
Properties
Count
Gets the number of rows in the view: the items, plus one header row for each top-level group when the view is grouped.
Value. The number of rows.
Groups
Always null , so that an items control lays this view out as one flat list, with the group headers among the rows, instead of generating a group item per group.
Value. null .
GroupsCount
Gets the groups count.
Value. The groups count.
Methods
GetCheckForVirtualizedGroupHeaders
Gets whether to check for virtualized group headers.
GetIsCurrentItemAVirtualizedGroupHeader
Gets whether the current item is a virtualized group header.
GetItemAt
Retrieves the item at the specified position in the view.
- index
- The zero-based index at which the item is located.
Returns. The item at the specified position in the view.
- ArgumentOutOfRangeException
- If
indexis out of range.
IndexOf
Returns the position of an item in the view, counting one row for each group header before it.
- item
- An item, or a
CollectionViewGroupfor a header row.
Returns. The zero-based position, or -1 if the item is not in the view.
OnCollectionChanged
Raises the CollectionChanged event with its indices counted in rows, header rows included, as the items control reads them.
- args
- The data for the event.
SetCheckForVirtualizedGroupHeaders
Sets whether to check for virtualized group headers.
SetIsCurrentItemAVirtualizedGroupHeader
Sets whether the current item is a virtualized group header.
SetIsCurrentItemAVirtualizedGroupHeaderProperty
Sets whether the current item is a virtualized group header. The same as SetIsCurrentItemAVirtualizedGroupHeader, which is the name XAML looks for.
Fields
CheckForVirtualizedGroupHeadersProperty
Identifies the attached property that asks this view to keep IsCurrentItemAVirtualizedGroupHeaderProperty up to date on an item container, following the container's data context as it is realised and reused.
IsCurrentItemAVirtualizedGroupHeaderProperty
Identifies the attached property that is true on an item container whose data context is a group header row. It is kept up to date only on containers that have CheckForVirtualizedGroupHeadersProperty set.