Skip to content

Commit f23427f

Browse files
authored
Update window-center-horizontally-fixed-top.md (#3417)
1 parent a6782ec commit f23427f

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

knowledge-base/window-center-horizontally-fixed-top.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ To center a Telerik Window horizontally while maintaining a fixed distance from
3636
>caption Telerik Blazor Window Centered Horizontally with Fixed Top Value
3737
3838
````RAZOR
39-
<TelerikButton OnClick="@( () => WindowVisible = !WindowVisible )">Toggle Window</TelerikButton>
39+
<TelerikButton OnClick="@(() => WindowVisible = !WindowVisible)">Toggle Window</TelerikButton>
40+
<TelerikButton OnClick="@OnResetButtonClick">Reset Position</TelerikButton>
4041
4142
<style>
4243
.k-centered.centered-top {
@@ -45,8 +46,11 @@ To center a Telerik Window horizontally while maintaining a fixed distance from
4546
}
4647
</style>
4748
48-
<TelerikWindow @bind-Visible="@WindowVisible"
49-
Class="centered-top" >
49+
<TelerikWindow @ref="@WindowRef"
50+
Class="centered-top"
51+
@bind-Top="@WindowTop"
52+
@bind-Left="@WindowLeft"
53+
@bind-Visible="@WindowVisible">
5054
<WindowActions>
5155
<WindowAction Name="Minimize" />
5256
<WindowAction Name="Close" />
@@ -60,7 +64,17 @@ To center a Telerik Window horizontally while maintaining a fixed distance from
6064
</TelerikWindow>
6165
6266
@code {
67+
private TelerikWindow? WindowRef { get; set; }
6368
private bool WindowVisible { get; set; } = true;
69+
private string WindowTop { get; set; } = string.Empty;
70+
private string WindowLeft { get; set; } = string.Empty;
71+
72+
private void OnResetButtonClick()
73+
{
74+
WindowTop = string.Empty;
75+
WindowLeft = string.Empty;
76+
WindowRef!.Refresh();
77+
}
6478
}
6579
````
6680

0 commit comments

Comments
 (0)