TelerikWindow: How to center with dynamic content?

1 Answer 12 Views
Window
Rodolfo
Top achievements
Rank 1
Rodolfo asked on 26 Sep 2025, 10:31 AM

In version 8.x we have the Center=true property which centered the window.

Now with the version 9.1 and Top + Left at 50% the window starts centered, but if we dynamically change the content inside of the window, the window expands to down-right and stopped to be centered.

I had to use a css to force the window to be always centered, but it's hack I don't like.

This is the old version:

<TelerikWindow Modal="true" @bind-Visible="@IsModalTaxValidateVisible" Resizable="true" Centered="true" MaxWidth="700px">

The new version:

<TelerikWindow Modal="true" @bind-Visible="@IsModalTaxValidateVisible" Resizable="true" Class="div_centered" MaxWidth="700px" Top="50%" Left="50%">
Does we have to call any event on the window to reposition if the content inside changed?

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 26 Sep 2025, 11:16 AM

Hi Rodolfo,

There is no need to do anything special in order to maintain a centered Window when its content changes:

https://blazorrepl.telerik.com/GzYDQAFl16k4ZpmQ14

<TelerikWindow Visible="true" MaxWidth="700px">
    <WindowTitle>
        Window Title
    </WindowTitle>
    <WindowContent>
        <p style="text-align:center"><TelerikButton OnClick="@( () => { } )">Click Me</TelerikButton></p>
        <p>@GenerateWindowContent()</p>
    </WindowContent>
</TelerikWindow>

@code {
    private bool WindowVisible { get; set; }

    private string GenerateWindowContent()
    {
        string result = string.Empty;

        int length = Random.Shared.Next(0, 100);

        for (int i = 0; i < length; i++)
        {
            result += string.Concat(" ", (char)Random.Shared.Next(65, 91));
        }

        return result;
    }
}

 

Regards,
Dimo
Progress Telerik

Your perspective matters! Join other professionals in the State of Designer-Developer Collaboration 2025: Workflows, Trends and AI survey to share how AI and new workflows are impacting collaboration, and be among the first to see the key findings.
Start the 2025 Survey
Rodolfo
Top achievements
Rank 1
commented on 26 Sep 2025, 11:51 AM

Yes. It worked... I think the Left was breaking it.

Thank you.

Tags
Window
Asked by
Rodolfo
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or