Dialog do not refresh its content

hello,
I'm looking for a solution to the problem shown by the following code snippet. As you can see, it's a simple component that opens a Dialog in which there is a button that increments a counter. The counter value is displayed in both the component and the Dialog. When I click on the button I can see the updated value in the component but not in the Dialog. To get the update in the Dialog I just have to move it around a bit (it's draggable).

@inject DialogService dialogService;
<h3>TestDialog</h3>

<RadzenText Text=@counter.ToString() />
<br />
<RadzenButton Text="Open Dialog" Click="OpenDialog" />

@code {
    int counter = 0;

    private void Click()
    {
        counter++;
    }

    private async void OpenDialog()
    {
        await dialogService.OpenAsync("Dialog", ds => @DialogFragment(),
                    new DialogOptions()
                        {
                            Width = "980px",
                            Resizable = true,
                            Draggable = true
                        }
                );
    }

    private RenderFragment DialogFragment()
    {
        return
    @<RadzenCard>
        <RadzenText Text=@counter.ToString() />
        <br />
        <RadzenButton Text="Click me" Click="Click" />
    </RadzenCard>;
    }
}

Is there anything I can do to get the correct behavior?
Thank you very much

You can call DialogService Refresh() method:

Thanks for the quick response!
I really don't like the solution of calling dialogService.Refresh from the contents of the Dialog. In a generic scenario there could be any component in the Dialog (including a third party component) and it doesn't look like the responsibility for calling dialogService.Refresh could be assigned to it.
With this in mind, I tried to assign responsibility to the main component (the one that opens the Dialog) with the following code:

protected override bool ShouldRender()
        {
            bool sr = base.ShouldRender();            
            if (sr)          
                    dialogService?.Refresh();                                                                           
            return sr;
        }        

While it works in 90% of cases, there are situations where it produces an infinite loop (it depends on the component you place in the Dialog). Any suggestions on this? Is there a way to know if the Dialog refresh has already been done to avoid doing it when not needed?
Thanks again!

You can check the code for reference:

If you have some ideas for improvements we accept pull requests!