public sealed class VirtualizingGridA wrapping grid of which only what is on screen exists as elements.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
VirtualizingPanel's bargain in two dimensions. The items are the caller's and the tiles are a pool; this control knows how many items there are and how big a tile is, and nothing about what an item is. Forty thousand of them is forty thousand of the caller's own objects and about sixty elements.
⚠ Its own control rather than a mode on the panel, and the reason is one number. A list's row occupies the full width, so item n is at n × height and nothing else is needed. A grid's item is at a position that depends on Columns, which is a function of the measured width — so the same resize that changes the viewport also changes which item is where, and the content height with it. Folding that into a control whose entire premise is "row n is at n × height" would make every line of it conditional.
⚠ Tiles are a fixed size, from --tile-width and --tile-height. The same reason a row has a fixed height: knowing where item 40 000 is without having measured the 39 999 before it is what makes this arithmetic instead of a walk. A grid of tiles that sized themselves to their captions would also be one whose columns moved as you typed in a search box, which is a grid you cannot aim at.
⚠ Nothing has to call Realise. It runs on LayoutFinished, which is the only place that knows how wide the viewport ended up — and for a grid that matters more than for a list, because the width is what decides the layout rather than merely how much of it is visible.
Fields and properties (13)
public const int OverscanHow many lines of tiles are realised above and below the viewport.
protected override string TagNameThe element name this type answers to when a caller does not choose one.
protected override bool AcceptsFocusWhether the focus can rest on this kind of control at all.
public ScrollView ScrollerThe scroller the tiles live in.
public IReadOnlyList<UiElement> TilesThe tiles that exist as elements, in pool order rather than in item order.
public int FirstItemWhich item the first tile of the pool is showing.
public int ColumnsHow many tiles fit across, as of the last realise.
public float TileWidthHow wide a tile is, from --tile-width.
public float TileHeightHow tall a tile is, from --tile-height.
public int Countpublic Func<VirtualizingGrid, UiElement>? CreateTileMakes a tile element. Called only when the pool has to grow.
public Action<UiElement, int>? BindTilePuts an item's data on a tile.
public static readonly UiPropertyKey CountPropertyIdentity for Count.
Methods (6)
protected override void OnCreated()Builds whatever this element is made of, once, as it joins a document.
protected override void OnRemoved()Called once, as the element leaves the document.
public UiElement? TileOf(int item)The element showing an item, or null if it is not realised.
public void ScrollIntoView(int item)Scrolls until an item is inside the viewport.
public void Realise()Makes sure there is a tile for every visible one, and binds them.
public void ClearCount()Unsets Count, so it takes its default or its ancestor's value again.
Used by (2)
- VirtualizingGridTestsVixen.Ui.Controls.Tests
- AssetGridVixen.Editor.App