HypernovaDesktop Components · docs
Binarymission
WPF › Virtualizing Collection View › VirtualizingCollectionView

VirtualizingCollectionView

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WPF.Data.DataExtensions

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

VirtualizingCollectionViewInitializes a new instance of the VirtualizingCollectionView class.
CountGets the number of rows in the view: the items, plus one header row for each top-level group when the view is grouped.
GroupsAlways 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.
GroupsCountGets the groups count.
GetCheckForVirtualizedGroupHeadersGets whether to check for virtualized group headers.
GetIsCurrentItemAVirtualizedGroupHeaderGets whether the current item is a virtualized group header.
GetItemAtRetrieves the item at the specified position in the view.
IndexOfReturns the position of an item in the view, counting one row for each group header before it.
OnCollectionChangedRaises the CollectionChanged event with its indices counted in rows, header rows included, as the items control reads them.
SetCheckForVirtualizedGroupHeadersSets whether to check for virtualized group headers.
SetIsCurrentItemAVirtualizedGroupHeaderSets whether the current item is a virtualized group header.
SetIsCurrentItemAVirtualizedGroupHeaderPropertySets whether the current item is a virtualized group header. The same as SetIsCurrentItemAVirtualizedGroupHeader, which is the name XAML looks for.
CheckForVirtualizedGroupHeadersPropertyIdentifies 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.
IsCurrentItemAVirtualizedGroupHeaderPropertyIdentifies 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

public VirtualizingCollectionView(IList list) : base(list)

Initializes a new instance of the VirtualizingCollectionView class.

list
The underlying collection, which must implement IList.

Properties

Count

public override int 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

public override ReadOnlyObservableCollection<object> 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

public int GroupsCount

Gets the groups count.

Value. The groups count.

Methods

GetCheckForVirtualizedGroupHeaders

public static bool GetCheckForVirtualizedGroupHeaders(DependencyObject obj)

Gets whether to check for virtualized group headers.

GetIsCurrentItemAVirtualizedGroupHeader

public static bool GetIsCurrentItemAVirtualizedGroupHeader(DependencyObject obj)

Gets whether the current item is a virtualized group header.

GetItemAt

public override object GetItemAt(int index)

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 index is out of range.

IndexOf

public override int IndexOf(object item)

Returns the position of an item in the view, counting one row for each group header before it.

item
An item, or a CollectionViewGroup for a header row.

Returns. The zero-based position, or -1 if the item is not in the view.

OnCollectionChanged

protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs args)

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

public static void SetCheckForVirtualizedGroupHeaders(DependencyObject obj, bool value)

Sets whether to check for virtualized group headers.

SetIsCurrentItemAVirtualizedGroupHeader

public static void SetIsCurrentItemAVirtualizedGroupHeader(DependencyObject obj, bool value)

Sets whether the current item is a virtualized group header.

SetIsCurrentItemAVirtualizedGroupHeaderProperty

public static void SetIsCurrentItemAVirtualizedGroupHeaderProperty(DependencyObject obj, bool value)

Sets whether the current item is a virtualized group header. The same as SetIsCurrentItemAVirtualizedGroupHeader, which is the name XAML looks for.

Fields

CheckForVirtualizedGroupHeadersProperty

public static readonly DependencyProperty 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

public static readonly DependencyProperty 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.