Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor Virtualize with ItemsProvider causes build error that I do not understand

$
0
0

The virtualize part:

<Virtualize ItemsProvider="LoadVisibleProducts" OverscanCount="10" Context="product"><ItemContent><div style="height: 50px;"><div class="col-12 mb-3 bg-white p-3 d-flex shadow gap-3"><div class="img-container shadow"><img class = "product-img" src="@product.ImageUrl" alt="" /></div></div></div></ItemContent></Virtualize>

The functions:

ProductDto[] _products = [];ProductDto product;protected override async Task OnInitializedAsync(){    _products = await ProductApi.GetProductsAsync1(0, 5);}private async Task<ItemsProviderResult<ProductDto>> LoadVisibleProducts(ItemsProviderRequest request){    var magar = await ProductApi.GetProductsAsync1(request.StartIndex, request.Count);    foreach (var cartItem in CartService.Items)    {        var product = magar.FirstOrDefault(p => p.Id == cartItem.ProductId);        if (product != null)        {            product.Quantity = cartItem.Quantity;        }    }    return new ItemsProviderResult<ProductDto>(magar, magar.Length);}

Error:

The type arguments for method 'TypeInference.CreateVirtualize_0(RenderTreeBuilder, int, int, ItemsProviderDelegate, int, int, int, RenderFragment)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

You can't provide arguments explicitly in ItemsProvider, or will throw an error that it can't convert arguments....

So my guess this wasn't implemented to use models dtos..... and I need confirmation from you.

I used this example https://learn.microsoft.com/en-us/aspnet/core/blazor/components/virtualization?view=aspnetcore-9.0


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>