ant-design-blazor / ant-design-blazor

đŸŒˆA set of enterprise-class UI components based on Ant Design and Blazor.

Home Page:https://antblazor.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ImagePreviewGroup throw null if image count = 0

rq204 opened this issue · comments

the code is

<ImagePreviewGroup @bind-PreviewVisible="imgvisible">
    @{
        if (imgs != null)
        {
            foreach (string imgurl in imgs)
            {
                <Image Width="200" Src="@imgurl" PreviewSrc="@imgurl" />
            }
        }
    }
</ImagePreviewGroup>

when imgvisible is changed,the source code components/image
/ImagePreviewGroup.razor.cs like that

 public void HandleVisibleChange(bool visible)
        {
            if (visible)
            {
                _imageRef = ImageService.OpenImages(_images);
                _imageRef.SwitchTo(0);
                _imageRef.OnClosed += OnPreviewClose;
            }
            else
            {
                if (_imageRef != null)
                {
                    _imageRef.OnClosed -= OnPreviewClose;
                    ImageService.CloseImage(_imageRef);
                }
            }

            if (PreviewVisibleChanged.HasDelegate)
            {
                PreviewVisibleChanged.InvokeAsync(visible);
            }
        }

where _images.Count=0 ,_imageRef.SwitchTo(0); Error。