-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathVirtualListFactories.cs
More file actions
37 lines (34 loc) · 1.16 KB
/
VirtualListFactories.cs
File metadata and controls
37 lines (34 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using Microsoft.UI.Reactor.Core;
using Microsoft.UI.Reactor.Controls;
namespace Microsoft.UI.Reactor;
public static partial class Factories
{
/// <summary>
/// Creates a VirtualList element — a count-based virtualized list.
/// Items are rendered on demand via the renderItem callback.
/// </summary>
public static ComponentElement VirtualList(
int itemCount,
Func<int, Element> renderItem,
Func<int, string>? getItemKey = null,
double? itemHeight = null,
double estimatedItemHeight = 40,
double spacing = 0,
Action<VirtualListRef>? @ref = null,
Action<int, int>? onVisibleRangeChanged = null)
{
var props = new VirtualListElement
{
ItemCount = itemCount,
RenderItem = renderItem,
GetItemKey = getItemKey,
ItemHeight = itemHeight,
EstimatedItemHeight = estimatedItemHeight,
Spacing = spacing,
Ref = @ref,
OnVisibleRangeChanged = onVisibleRangeChanged,
};
return Component<VirtualListComponent, VirtualListElement>(props)
.WithKey($"vl-{itemCount}");
}
}