From 8aad0a89cda809e7da911212c8ba80a9d6b2e8ee Mon Sep 17 00:00:00 2001 From: Alex Oswald Date: Sun, 12 Dec 2021 14:44:21 -0800 Subject: [PATCH 1/2] Add EmptyContent to Virtualize --- src/Components/Web/src/Virtualization/Virtualize.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Components/Web/src/Virtualization/Virtualize.cs b/src/Components/Web/src/Virtualization/Virtualize.cs index 40d5af6d29df..59c62ba36d82 100644 --- a/src/Components/Web/src/Virtualization/Virtualize.cs +++ b/src/Components/Web/src/Virtualization/Virtualize.cs @@ -55,7 +55,7 @@ public sealed class Virtualize : ComponentBase, IVirtualizeJsCallbacks, I private IJSRuntime JSRuntime { get; set; } = default!; /// - /// Gets or sets the item template for the list. + /// Gets or sets the child content for the list. /// [Parameter] public RenderFragment? ChildContent { get; set; } @@ -66,6 +66,12 @@ public sealed class Virtualize : ComponentBase, IVirtualizeJsCallbacks, I [Parameter] public RenderFragment? ItemContent { get; set; } + /// + /// Gets or sets the empty content. + /// + [Parameter] + public RenderFragment? EmptyContent { get; set; } + /// /// Gets or sets the template for items that have not yet been loaded in memory. /// @@ -193,6 +199,11 @@ protected override void BuildRenderTree(RenderTreeBuilder builder) builder.OpenRegion(3); + if (EmptyContent is not null && _itemCount == 0) + { + EmptyContent(builder); + } + // Render placeholders before the loaded items. for (; renderIndex < placeholdersBeforeCount; renderIndex++) { From 92671feecc25ca98069631d15ed811b766bab24e Mon Sep 17 00:00:00 2001 From: Alex Oswald Date: Mon, 13 Dec 2021 10:31:23 -0800 Subject: [PATCH 2/2] Update src/Components/Web/src/Virtualization/Virtualize.cs Co-authored-by: Pranav K --- src/Components/Web/src/Virtualization/Virtualize.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Web/src/Virtualization/Virtualize.cs b/src/Components/Web/src/Virtualization/Virtualize.cs index 59c62ba36d82..d1e233bd0026 100644 --- a/src/Components/Web/src/Virtualization/Virtualize.cs +++ b/src/Components/Web/src/Virtualization/Virtualize.cs @@ -67,7 +67,7 @@ public sealed class Virtualize : ComponentBase, IVirtualizeJsCallbacks, I public RenderFragment? ItemContent { get; set; } /// - /// Gets or sets the empty content. + /// Gets or sets the `` that is used when no items are available. /// [Parameter] public RenderFragment? EmptyContent { get; set; }