Blazor ProgressBar Visible Flag

Okay so ... I got it to work by sticking it in an @if like so:

        @if (_message.Length > 0)
        {
            <RadzenProgressBar Value="100" ShowValue="false" Mode="ProgressBarMode.Indeterminate" Style="margin-bottom: 20px" />

        }

Then in the @code I am setting the value of the message. You could use really any variable but the main thing is to be sure to make the async calls properly so the control starts to move while your long running process is under way.

@code {

    private string _message = String.Empty;

    void UpdateData(MouseEventArgs e, int number)
    {
        _message = "processing";
        Task.Run(() => Refresher());
        StateHasChanged();
    }

    void Refresher()
    {
        //make your long running API call here (I injected a service for that)
        _message = String.Empty;
       //This is necessary because we are in another thread
        InvokeAsync(() => {
            StateHasChanged();
        });
    }
}

Might help someone, but it definitely solved my problem.

1 Like